[Newbies] Block and Closure

Bert Freudenberg bert at freudenbergs.de
Fri Apr 10 07:54:08 UTC 2009


On 10.04.2009, at 05:48, Randal L. Schwartz wrote:

>>>>>> "K" == K K Subramaniam <subbukk at gmail.com> writes:
>
> K> In Squeak, i in the block will refer to the i in the do: block  
> and the last
> K> statement will print 25 because i would be 5 when do: terminates.
>
> Not necessarily. I could see an implementation where i would be 4.


And how exactly does that statement help a beginner to understand the  
distinction between a BlockContext and a BlockClosure? ;)

Andrey: Both are pretty much the same, there is no change in syntax.  
Closures simply are Blocks Done Right.

Try to run the example Subbu mentioned, and see if you would have  
expected the result or not. With closures it does what one would expect.

- Bert -




More information about the Beginners mailing list