Stéphane Rollandin wrote:
Julian Fitzell a écrit :
I'm assuming this is caused by Squeak's lack of full block closures.
Does it work if you make "y" an instance variable instead of a local?
Julian
actually, trying the following does work in a workspace or a method:
| y | y _ Continuation currentDo: [:c | c]. Transcript show: 1. Continuation currentDo: [:c | y value: c]. Transcript show: 2. Continuation currentDo: [:c | y value: c]. Transcript show: 3.
so the problem occurs when y is an instance variable, while it works fine with a local variable (although if you try the code above in a workspace without declaring the | y | in the first line, it fails)
Indeed in GNU Smalltalk I get Squeak's behavior if y is a global, while I get the correct behavior if y is a local. You get the latter with
Eval [ |y| y _ Continuation currentDo: [:c | c]. 1 printNl. Continuation currentDo: [:c | y value: c]. 2 printNl. Continuation currentDo: [:c | y value: c]. 3 printNl. ]
and the former by removing "|y|" (which makes y work across multiple Evals) in GNU Smalltalk's REPL.