From: Dave Bakhash
Subject: LOOP and special variables
Date: 
Message-ID: <c29vg8h63lt.fsf@no-knife.mit.edu>
Hi,

for the first time I've wanted to define a LOOP variable that was
special...similar to:

(let ((*foo* 3))
 (declare (special *foo*))
 ...)

also, similar to what DOTIMES allows.  But I don't think that LOOP can
do it.  I searched google groups, and found this:

http://groups.google.com/groups?hl=en&lr=&ie=UTF8&oe=UTF8&threadm=70o7mq%241eh%40pravda.cc.gatech.edu&rnum=4&prev=/groups%3Fq%3Dgroup%253Acomp.lang.lisp%2Bloop%2Bspecial%26ie%3DUTF8%26oe%3DUTF8%26hl%3Den%26btnG%3DGoogle%2BSearch

is it really true that LOOP does not allow special variables?

If not, what's the best work-around?  is it to do a:

(defun print-foo ()
  (declare (special *foo*))
  (print *foo*))

(locally
 (declare (special *foo*))
 (loop
   for *foo* in '(1 2 3)
   do (print-foo)))

I don't even think that works.

This doesn't bode well for LOOP.

dave

From: Barry Margolin
Subject: Re: LOOP and special variables
Date: 
Message-ID: <2TrP8.17$DO2.386@paloalto-snr1.gtei.net>
In article <···············@no-knife.mit.edu>,
Dave Bakhash  <·····@alum.mit.edu> wrote:
>is it really true that LOOP does not allow special variables?

It doesn't provide a way to make it generate special declarations in its
output.

>
>If not, what's the best work-around?  is it to do a:
>
>(defun print-foo ()
>  (declare (special *foo*))
>  (print *foo*))
>
>(locally
> (declare (special *foo*))
> (loop
>   for *foo* in '(1 2 3)
>   do (print-foo)))
>
>I don't even think that works.
>
>This doesn't bode well for LOOP.

It seems like this variable should be proclaimed special globally,
presumably with a DEFVAR definition.  If so, the pervasiveness of that
special proclamation will include the use of the variable in LOOP.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Dave Bakhash
Subject: Re: LOOP and special variables
Date: 
Message-ID: <c29r8j561jl.fsf@no-knife.mit.edu>
Barry Margolin <······@genuity.net> writes:

> It seems like this variable should be proclaimed special globally,
> presumably with a DEFVAR definition.  If so, the pervasiveness of that
> special proclamation will include the use of the variable in LOOP.

I guess so...but if you use DEFVAR, you might want to use it without
supplying the optional value, since you may not want to shadow the
global binding, etc.  at least...that's the case in my particular
application.  I'd rather use DECLAIM than DEFVAR.

dave
From: Barry Margolin
Subject: Re: LOOP and special variables
Date: 
Message-ID: <GytP8.17$dK4.1491@paloalto-snr2.gtei.net>
In article <···············@no-knife.mit.edu>,
Dave Bakhash  <·····@alum.mit.edu> wrote:
>Barry Margolin <······@genuity.net> writes:
>
>> It seems like this variable should be proclaimed special globally,
>> presumably with a DEFVAR definition.  If so, the pervasiveness of that
>> special proclamation will include the use of the variable in LOOP.
>
>I guess so...but if you use DEFVAR, you might want to use it without
>supplying the optional value, since you may not want to shadow the
>global binding, etc.  at least...that's the case in my particular
>application.  I'd rather use DECLAIM than DEFVAR.

DEFVAR is supposed to be the way you initially declare it to be special; it
should be done before any other functions assign a global value to it.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Barry Margolin
Subject: Re: LOOP and special variables
Date: 
Message-ID: <LztP8.18$DO2.334@paloalto-snr1.gtei.net>
In article <···············@no-knife.mit.edu>,
Dave Bakhash  <·····@alum.mit.edu> wrote:
>Barry Margolin <······@genuity.net> writes:
>
>> It seems like this variable should be proclaimed special globally,
>> presumably with a DEFVAR definition.  If so, the pervasiveness of that
>> special proclamation will include the use of the variable in LOOP.
>
>I guess so...but if you use DEFVAR, you might want to use it without
>supplying the optional value, since you may not want to shadow the
>global binding, etc.  at least...that's the case in my particular
>application.  I'd rather use DECLAIM than DEFVAR.

If it already has a value, DEFVAR won't overwrite it.  That's what
DEFPARAMETER does.


-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.