Subject: Re: is this a portable CL? (rebind)
From: rpw3@rpw3.org (Rob Warnock)
Date: Thu, 08 Mar 2007 04:22:06 -0600
Newsgroups: comp.lang.lisp
Message-ID: <3KmdnbiVM9VTfnLYnZ2dnUVZ_ozinZ2d@speakeasy.net>
Tim Bradshaw <tfb+google@tfeb.org> wrote:
+---------------
| "Alex Mizrahi" <udode...@users.sourceforge.net> wrote:
| > CL-USER> (loop for fun in
| >         (loop for obj in '(1 2 3 4 5)
| >        collect (let ((obj obj)) (lambda () obj)))
| >         collect (funcall fun))
| > (1 2 3 4 5)
| >
| > however, i'm not sure that this fix works according to
| > Common Lisp standard.
| 
| Yes, this is the right way of doing this.
+---------------

Though it would be a *lot* easier to read if written this way:

    > (loop for item in '(1 2 3 4 5)
	collect (let ((obj item)) (lambda () obj)))

    (#<Interpreted Function "LOOP FOR" {489410B1}>
     #<Interpreted Function "LOOP FOR" {48941141}>
     #<Interpreted Function "LOOP FOR" {489411D1}>
     #<Interpreted Function "LOOP FOR" {48941261}>
     #<Interpreted Function "LOOP FOR" {489412F1}>)
    > (mapcar 'funcall *)

    (1 2 3 4 5)
    > 


-Rob

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