[squeak-dev] Variable capture in block closure

Eliot Miranda eliot.miranda at gmail.com
Mon Jan 21 19:44:47 UTC 2019


Hi Stef,

On Jan 21, 2019, at 10:43 AM, Stéphane Rollandin <lecteur at zogotounga.net> wrote:

>> just curious - which of those surprises you?
> 
> The first one. I expected the block to capture the variable value at the block creation time, but from Tony's answer I now see why it does not work that way.

But the second example *does* capture x at block creation time. In the second example a single block is evaluated three times, each time creating a new x (x being a variable that comes into existence when the block is evaluated) and then three times a block nested within it is created, capturing x at block creation time.

> 
> Stef
> 


More information about the Squeak-dev mailing list