help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Closures - do you understand them well?


From: Emanuel Berg
Subject: Re: Closures - do you understand them well?
Date: Fri, 09 Dec 2022 22:23:21 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Tassilo Horn wrote:

> This time I'm prepared and have three versions making a new
> binding. Take this, Michael! :-)
>
> (let ((i 0)
>       (m (lambda (i)
>            (lambda () i)))
>       funs)
>   (while (< i 100)
>     (push (funcall m i) funs)
>     (cl-incf i))
>   (mapcar #'funcall funs))

Same.

> (let ((i 0)
>       funs)
>   (while (< i 100)
>     (let ((j i))
>       (push (lambda () j) funs))
>     (cl-incf i))
>   (mapcar #'funcall funs))

DNC ...

> (let ((i 0)
>       funs)
>   (while (< i 100)
>     (push `(lambda () ,i) funs)
>     (cl-incf i))
>   (mapcar #'funcall funs))

Yes, but here there is no "new binding" exactly, rather the
value is hard-coded onto the lambda ...

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]