Subject: Re: Loop curiosity
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 07 Jan 2009 22:16:08 -0600
Newsgroups: comp.lang.lisp
Message-ID: <Z4GdnbpWS_uV4_jUnZ2dnUVZ_qXinZ2d@speakeasy.net>
Kaz Kylheku  <kkylheku@gmail.com> wrote:
+---------------
| Pascal Costanza <pc@p-cos.net> wrote:
| > Hm, the following seems to go into an endless loop in two Lisp 
| > implementations I checked:
| >    (loop finally (print 'screw-you))
| > Is this according to the spec?
...
| It's not a simple loop form ... So this is an extended loop with a FINALLY
| clause that is never reached, since there is no termination test, nor any
| explicit LOOP-FINISH or RETURN.
| 
| 6.1.1.6 Order of Execution says: ``Execution is repeated until a clause
| terminates the loop or until a return, go or throw form is encountered
| which transfers control to a point outside the loop.''
+---------------

CMUCL, for one, seems to agree:

    cmu> (macroexpand
	  '(loop finally (print 'screw-you)))

    (BLOCK NIL (ANSI-LOOP::LOOP-BODY NIL NIL NIL NIL ((PRINT 'SCREW-YOU))))
    T
    cmu> (macroexpand
	  '(ANSI-LOOP::LOOP-BODY NIL NIL NIL NIL ((PRINT 'SCREW-YOU)))
    )

    (TAGBODY
     ANSI-LOOP::NEXT-LOOP
      (GO ANSI-LOOP::NEXT-LOOP)
     ANSI-LOOP::END-LOOP
      (PRINT 'SCREW-YOU))
    T
    cmu> 


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607