[Openmcl-devel] Closures

Ron Garret ron at flownet.com
Sun Apr 20 10:20:40 PDT 2014


You might want to read this:

http://www.flownet.com/ron/specials.pdf

On Apr 20, 2014, at 4:34 AM, Taoufik Dachraoui <dachraoui.taoufik at gmail.com> wrote:

> Hi
> 
> Can someone explain the following:
> 
> ? (let ((fn nil)) (dotimes (k 2) (push (lambda () (print k)) fn)) (dolist (f fn) (funcall f)))
> 
> 2 
> 2 
> NIL
> ? (let ((fn nil)) (dotimes (k 2) (let ((r k)) (push (lambda () (print r)) fn))) (dolist (f fn) (funcall f)))
> 
> 1 
> 0 
> NIL
> ? (defvar r 10)
> R
> ? (let ((fn nil)) (dotimes (k 2) (let ((r k)) (push (lambda () (print r)) fn))) (dolist (f fn) (funcall f)))
> 
> 10     ?????
> 10     ?????
> NIL
> ?
> 
> Kind regards
> Taoufik
> 
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://lists.clozure.com/mailman/listinfo/openmcl-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20140420/bd0034a4/attachment.bin>


More information about the Openmcl-devel mailing list