Wednesday, September 16, 2009

Blocks in Smalltalk can have their own temporary variables

Did you know that the following appears to be Smalltalk code? Runs fine in the current Pharo.

[:a | |b| 2] value: 3

4 comments:

  1. Yes, of course they can (even though Pharo ignores the nesting and turns them into top-level temp vars, lulz)

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. That will be fixed in the NewCompiler along with all other problems of mankind :)

    ReplyDelete
  4. akuhn, it's not that easy. to begin with, in a printit they behave differently than in a method. In a method they very much behave. In a printIt, they can sort of escape their context.

    ReplyDelete

Note: Only a member of this blog may post a comment.