I'd like to put a declaration in the Loop Facility, something like this:
(loop
:for x :from 1 :to 10
:do (declare (fixnum x))
(print x))
but this doesn't seem to work. It is, however, possible to put decls in
other iteration constructs, like:
(do ((x 1 (+ x 1)))
((> x 10))
(declare (fixnum x))
(print x))
Is it impossible to put declarations in Loop? If so, is there a reason
why, or have the folks at X3J13 overlooked it?
--SRS
Sent via Deja.com http://www.deja.com/
Before you buy.
In article <············@nnrp1.deja.com>, SRS <·····@my-deja.com>
wrote:
> I'd like to put a declaration in the Loop Facility, something like this:
>
> (loop
> :for x :from 1 :to 10
> :do (declare (fixnum x))
> (print x))
>
(loop for x fixnum from 1 to 10 do ...
* SRS <·····@my-deja.com>
| Is it impossible to put declarations in Loop?
no, but it has a different syntax than other declarations:
(loop :for x :of-type fixnum :from 1 :to 100 :do ...)
note that "fixnum" is not a loop keyword, but the symbol naming the
type. see 6.1.1.7 [Loop] Destructuring in the standard.
#:Erik
In article <················@naggum.no>,
Erik Naggum <····@naggum.no> wrote:
> * SRS <·····@my-deja.com>
> | Is it impossible to put declarations in Loop?
>
> no, but it has a different syntax than other declarations:
>
> (loop :for x :of-type fixnum :from 1 :to 100 :do ...)
Thanks! But what about other, non-type, declarations, such as
(special ...) or (inline ...)
Do I have to use
(locally (declare (special x))
(loop ...))
--SRS
Sent via Deja.com http://www.deja.com/
Before you buy.
* SRS <·····@my-deja.com>
| But what about other, non-type, declarations, ...
Well, there's no special syntax for them, so you'd have to resort to
declarations inherited from superior forms or within inferior forms.
Please see the standard or other language reference on loop for the
rich set of details on loop.
#:Erik