Deutsch   English   Français   Italiano  
<v5e5oc$1gqis$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: "B. Pym" <No_spamming@noWhere_7073.org>
Newsgroups: comp.lang.lisp
Subject: Re: loop never + thereis
Date: Tue, 25 Jun 2024 10:22:08 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 92
Message-ID: <v5e5oc$1gqis$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Tue, 25 Jun 2024 12:22:08 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="12db3d8f8432161ef07f45f3e632390d";
	logging-data="1600092"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+6QF2JsEP5lZ1kNSYbHRyM"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:5lp00Dr1ijXwFYLgWbFQH6kmA3I=
Bytes: 3922

Pascal Bourguignon wrote:

> I find this while trying to compile ThinLisp in clisp 2.33.2:
> 
> *** - LOOP: ambiguous result of loop
> (LOOP FOR SUBFORM = (CAR SUBFORM-CONS) WHILE SUBFORM-CONS NEVER (ATOM SUBFORM)
>  THEREIS (EQUAL SUBFORM '(TL:GO TL::NEXT-LOOP)) DO
>  (SETF SUBFORM-CONS (CONS-CDR SUBFORM-CONS)))
> n++Break 1 TLI[7]>
> 
> 
> The formal syntax of LOOP does not impose any exclusion between always
> or never and thereis.
> 
> Here is what CLHS says about the default return value for always,
> never  and thereis:
> 
> always:   Otherwise, it provides a default return value of t.
> 
> never:    Unless some other clause contributes a return value, the
>           default value returned is t.
> 
> thereis:  Unless some other clause contributes a return value, the
>           default value returned is nil.
> 
> 
> So, the result specified by never and thereis seem to be in
> contradiction, but these clauses are not evaluated in parallel!

....

> Or for another example:
> 
>     (loop for i from 1 to 10 thereis nil never nil)
> 
> should return the default value of the last clause seen: T
> 
> 
> 
> 
> My reading of CLHS          -           T
> 
> ThinLisp source expects:    -           T
> 
> clisp   2.33.2              error       -
> 
> gcl     2.6.3               warning     NIL
> 
> ecl     0.9                 warning     T
> 
> cmucl   18e                 warning     T
> 
> sbcl    0.8.14.9            -           T       (issues a deleting
>                                                  unreachable code note
>                                                  as expected).
> 
> 
> So, the question is: what does the standard specify in the case where
> we mix ALWAYS or NEVER with THEREIS in a LOOP?


Paul Graham:

I consider Loop one of the worst flaws in CL, and an example
to be borne in mind by both macro writers and language designers.


[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.