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: Sat, 10 Dec 2022 05:46:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Tassilo Horn wrote:

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

OK, so `lexical-binding' required, that's why they don't work
in the article buffer but suddenly work when I yank them into
an Elisp buffer ...

(setq-default lexical-binding t)

anyone?

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




reply via email to

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