Lexical closures in Squeak
tim at sumeru.stanford.edu
Mon Aug 12 17:08:31 UTC 2002
Jason Dufair <jase at dufair.org> is claimed by the authorities to have written:
> With my recent venture into spawning Squeak processes, I have a
> question. From having lurked on the list for many months, I am under
> the impression that Squeak's blocks are not true lexical closures (and
> that someone(s) are working toward this). If this is true, then why
> does something like (forgive any errors - I'm going from memory)
> [ | delay |
> delay _ Delay forMilliseconds: 300.
> [streamingMp3File samplesRemaining = 0
> ifTrue: [self nextTrack].
> Process waitFor: delay]] fork.
It's a fudge to allow slightly easier filing in of code form
otheSmalltalks. The 'block temp' is simply moved into the method temps;
if you were to look at a context of this form in the debugger you
would almost certainly find the values of temps appear to be mixed up.
Anthony Hannan has done a great deal of work towards fixing the lack
of proper closures and is currently working on revising his code to work
with plain Contexts instead of the explicitly stacked system he worked
up. This will make it nice and simple to adapt to any dynamic
translation or even static translation system that appears. Should make
it nice and easy to do continuations and coroutining too.
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Strange OpCodes: MT: Muddle Through
More information about the Squeak-dev