Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Decls in Loop

4 views
Skip to first unread message

SRS

unread,
Apr 30, 2000, 3:00:00 AM4/30/00
to
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.

Rainer Joswig

unread,
Apr 30, 2000, 3:00:00 AM4/30/00
to
In article <8ehcp8$b7j$1...@nnrp1.deja.com>, SRS <sr...@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 ...

Erik Naggum

unread,
Apr 30, 2000, 3:00:00 AM4/30/00
to
* SRS <sr...@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

SRS

unread,
May 2, 2000, 3:00:00 AM5/2/00
to
In article <31660933...@naggum.no>,

Erik Naggum <er...@naggum.no> wrote:
> * SRS <sr...@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 ...))

Erik Naggum

unread,
May 2, 2000, 3:00:00 AM5/2/00
to
* SRS <sr...@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

0 new messages