From: SRS
Subject: Decls in Loop
Date: 
Message-ID: <8ehcp8$b7j$1@nnrp1.deja.com>
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.

From: Rainer Joswig
Subject: Re: Decls in Loop
Date: 
Message-ID: <rainer.joswig-D46F66.16263530042000@news.is-europe.net>
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 ...
From: Erik Naggum
Subject: Re: Decls in Loop
Date: 
Message-ID: <3166093389825776@naggum.no>
* 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
From: SRS
Subject: Re: Decls in Loop
Date: 
Message-ID: <8em8us$hhv$1@nnrp1.deja.com>
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.
From: Erik Naggum
Subject: Re: Decls in Loop
Date: 
Message-ID: <3166251224072130@naggum.no>
* 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