Implementing closures

Paolo Bonzini bonzini at gnu.org
Thu Dec 20 08:13:54 UTC 2007


tim Rowledge wrote:
> 
> On 19-Dec-07, at 8:19 PM, Andreas Raab wrote:
> 
>> Mathieu Suen wrote:
>>> Well so propose us your solution.
>>
>> Okay, I promised not to invent a solution but it's one of "those" 
>> problems that I've thought about for a while in the past so let's see. 
>> Here is how I would address the problem of implementing full closures 
>> in Squeak:
> 
> Well at a quick look it appears plausible - but I have a much simpler 
> idea. Eliot solved this problems in 1987 - in fact I *think* he was the 
> first so to do but wouldn't bet any large amount of money - and the 
> basics are described in his seminal paper from the 87 OOPSLa proceedings.

Note that Scheme interpreters have done this earlier than 1987 probably; 
Eliot was the first to bring the full power of lambdas to Smalltalk.

GNU Smalltalk's closures more or less follow the same style that Andreas 
outlined, except that as far as I understood he doesn't need 
BlockClosure objects because he keeps the bytecodes in the 
CompiledMethod rather than extracting them into a CompiledBlock.  This 
makes sense given Squeak's Smalltalk-80 legacy, and it looks like 
BrouHaHa did the same.

A very useful optimization is to implement copying blocks.  I've never 
found the time to implement it in GNU Smalltalk, but it should give 
interesting speedups.

Paolo




More information about the Squeak-dev mailing list