[Openmcl-devel] Closures

Taoufik Dachraoui dachraoui.taoufik at gmail.com
Sun Apr 20 11:37:11 UTC 2014


This shows that we need to be careful not to use a symbol in let that is
already defined by defvar (unless that is what we want

Regards
Taoufik



On Sun, Apr 20, 2014 at 1:34 PM, 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20140420/a0ea3fe6/attachment.html>


More information about the Openmcl-devel mailing list