[Newbies] Immutable environments in blocks?

Jeff G jgon.in.canada at gmail.com
Wed May 25 16:47:47 UTC 2011

Hi everyone,

My question is about the semantics of block closures in squeak. I played
around with scheme a bit in order to do some comparisons and one big
question I have is how to alter the outer environment from a closure.

An example of closure semantics given by Ian Piumarta on squeak-dev in 1999
is as follows.

mkCounter := [:init ¦ [init := init + 1]].
b1 := mkCounter value: 42.
b1 value. 43
b1 value. 44

I never get 44 returned from the current squeak trunk.  I only ever get 43,
which suggests to me that the assignment to init in the inner block is not
actually ever over writing the init value in the outer environment.  How
would I go about altering the outer environment from inside a block if I
desired to do so?

Thanks for all your help,
Jeff G.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20110525/0582c450/attachment.htm

More information about the Beginners mailing list