Subject: Re: something *very* strange (to *me*). Please help!
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 1997/10/07
Newsgroups: comp.lang.lisp
Message-ID: <61cbp9$17bi3@fido.asd.sgi.com>

Kent M Pitman <pitman@world.std.com> wrote:
+---------------
| ...i gets bound at the start of the DO and gets assigned at each step.
| You might in your head be thinking DO was just syntactic sugar for a tail
| recursion, but it is not documented that way...
+---------------

However, those of us who are mainly Scheme programmers (and who lurk here
to pick up general higher-level tips) might indeed make that assumption,
especially since a naive translation to Scheme does give the original
poster's "expected" result:

	> (let ((l (do ((i 0 (1+ i))
		        (r '()))
		       ((= i 3) (reverse r)) 
		     (set! r (cons (lambda () i) r))))) 
	    (map (lambda (x) (x)) l))
	(0 1 2)
	>

Just another reminder that there are subtle gotchas between Scheme & CL...

Thanks,


-Rob

-----
Rob Warnock, 7L-551		rpw3@sgi.com   http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673 [New area code!]
2011 N. Shoreline Blvd.		FAX: 650-933-4392
Mountain View, CA  94043	PP-ASEL-IA