Re: different LOOP results

Liste des GroupesRevenir à cl lisp 
Sujet : Re: different LOOP results
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp
Date : 23. Jun 2025, 10:09:41
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103b5kk$15h3o$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
Dr. Edmund Weitz wrote:

The following input
 
  (loop for x in '(1 2 3 4)
        for y upfrom 0
        collect x into temp
        when (oddp y)
          collect temp
          and do (print temp)
                 (setq temp nil))
 
results in
 
  (1 2)
  (3 4)
  ((1 2) (3 4))
 
with CLISP and LispWorks - which is what I expected. But CMUCL shows
 
  (1 2)
  (1 2 3 4)
  ((1 2 3 4) (1 2 3 4))
 
instead. Is this a bug or are both behaviors conforming?

In "ANSI Common Lisp", Graham makes the following comments:

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
23 Jun 25 o Re: different LOOP results1B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal