Em 18/01/2010 14:59, Lukas Renggli < renggli@gmail.com > escreveu:
The point is Pharo finally has real closures and sane execution semantics. The same semantics that all other Smalltalk dialects already had for decades, and the same semantics that Lisp, Scheme and even Javascript programmers trusted on in the last 40 years.
I agree with the sane semantics w.r.t. closures. However, Turba's post:
Em 16/01/2010 23:07, Tudor Girba <tudor.girba@gmail.com> escreveu:
I have a method that takes OBCommands and returns Actions:
actionsFrom: aCollectionOfOBCommandClasses on: aTarget for: aRequestor | command | ^ aCollectionOfOBCommandClasses collect: [ :each | command := each on: aTarget for: aRequestor. GLMAction new icon: command icon; title: command label; action: [:presentation | command execute ]; yourself ]
These actions have a block that will be executed at a later time. The problem here was that the command in the action block was always pointing to the same command object, even at each point the command variable was populated correctly.
However, when the command is defined inside the block, everything works as expected.
Makes me think the method would be work invariably of the position of the variable command (which is temporary for the method), because I see this analogous to (pls bear with me that in order to simplify the example I'm probably missing something!): temp := 1000. #(99 17 1 2 3 4 5 0 6 7 8 9) do: [:ea | temp := temp min: ea]. which after execution leaves temp with zero.
The previous block semantics on Pharo (and Squeak) were completely broken. The 'average Smalltalker' had to understand how contexts were setup and how the source is compiled to bytecode to explain the numerous hacks that were required for example in get the blocks behave sanely in Seaside. This is no longer necessary. The 'average Smalltalker' can just read the wikipedia page on closures.
OK about that! I'm obviously missing something, but perhaps being able to read this mailing only at night and tired is not helpin'!! []s -- Cesar Rabak