Loopy LOOP

Liste des GroupesRevenir à cl lisp 
Sujet : Loopy LOOP
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp
Date : 01. Sep 2024, 09:09:51
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vb13vt$1dnf9$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
P. Seibel wrote:

Pascal Bourguignon <spam@thalassa.informatimago.com> writes:
 
Peter Seibel <peter@....com> writes:
>
Pascal Bourguignon <spam@thalassa.informatimago.com> writes:
>
rpw3@rpw3.org (Rob Warnock) writes:
    > (loop for i below 4
            for j below 4
       finally (return (list i j)))
>
    (4 3)
    >
>
Oh. Duh.
>
LOOP is definitely one of the parts of CL where you learn something new
every day...  ;-}  ;-}
>
Actually, the variables i and j could very well not be available in
the finally clause.
>
How do you figure that? Why would the finally clause be any different
from any of the other clauses?
>
Note how clisp returns a conforming but differnet result too:
>
[193]> (loop for i below 4
             for j below 4
             finally (return (list i j)))
(4 4)
>
Hmmm. I'm not sure I buy that that's conforming. Given that LOOP
provides AND for specifying parallel stepping, why should CLISP's
behavior here be considered correct?
>
Because the loop variables don't have to be available in the finally
clause! If they're available, their value is unspecified.
 
And why do you say they don't have to be available in the finally
clause? Granted I can't see anything in the spec that *specifically*
says they have to be but I can't see anything that specifically says
they have to available *anywhere*. Why should the finally clause be
any different from any other LOOP clause?

In "ANSI Common Lisp", Paul Graham writes:

The loop macro was originally designed to help inexperienced
Lisp users write iterative code. Instead of writing Lisp code,
you express your program in a form meant to resemble English,
and this is then translated into Lisp.  Unfortunately, loop is
more like English than its designers ever intended: you can
use it in simple cases without quite understanding how it
works, but to understand it in the abstract is almost
impossible.
  ....
the ANSI standard does not really give a formal specification
of its behavior.
  ....
The first thing one notices about the loop macro is that it
has syntax.  A loop expression contains not subexpressions but
clauses.  The clauses are not delimited by parentheses;
instead, each kind has a distinct syntax.  In that, loop
resembles traditional Algol-like languages.  But the other
distinctive feature of loop, which makes it as unlike Algol as
Lisp, is that the order in which things happen is only
loosely related to the order in which the clauses occur.
  ....
For such reasons, the use of loop cannot be recommended.


Date Sujet#  Auteur
1 Sep 24 o Loopy LOOP1B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal