[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 06:37:01 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
tomas wrote:
>>> OK, so is it the closures? Or the loops?
>>>
>>> Or ... the lamdas?
>>>
>>> (setq x 111)
>>>
>>> (setq f (lambda () x))
>>>
>>> (funcall f)
>>>
>>> (setq x 222)
>>>
>>> (funcall f)
>>
>> Maybe I'm too tired, but I don't understand the question.
>> What's "it" in the first question?
>
> My gut reaction was such that the answer to Emanuel's
> question would have been "it's the bindings".
This is why you should never quote lambdas because if you do,
you get the intuitive result:
(let ((i 0)
(funs '()))
(while (< (setq i (1+ i))
4)
(push `(lambda () ,i)
funs))
(apply #'+ (mapcar #'funcall funs))) ; 6
--
underground experts united
https://dataswamp.org/~incal
- Re: Closures - do you understand them well?, (continued)
- Re: Closures - do you understand them well?, Emanuel Berg, 2022/12/10
- RE: [External] : Re: Closures - do you understand them well?, Drew Adams, 2022/12/10
- Iteration macros (was: [External] : Re: Closures - do you understand them well?), Stefan Monnier, 2022/12/10
- RE: Iteration macros (was: [External] : Re: Closures - do you understand them well?), Drew Adams, 2022/12/10
- Re: [External] : Re: Closures - do you understand them well?, Emanuel Berg, 2022/12/21
- Re: Closures - do you understand them well?, Emanuel Berg, 2022/12/08
- Re: Closures - do you understand them well?, Michael Heerdegen, 2022/12/08
- Re: Closures - do you understand them well?, tomas, 2022/12/08
- Re: Closures - do you understand them well?,
Emanuel Berg <=
- Re: Closures - do you understand them well?, Michael Heerdegen, 2022/12/09
- Re: Closures - do you understand them well?, Emanuel Berg, 2022/12/10
Re: Closures - do you understand them well?, Eric Abrahamsen, 2022/12/08
Re: Closures - do you understand them well?, Emanuel Berg, 2022/12/08