[squeak-dev] Cosmetic: move or remove a few temps inside closures

Juan Vuletich juan at jvuletich.org
Tue Dec 29 12:22:00 UTC 2009

Josh Gargus wrote:
> On Dec 27, 2009, at 7:50 PM, Eliot Miranda wrote:
>> On Sun, Dec 27, 2009 at 12:30 PM, Nicolas Cellier 
>> <nicolas.cellier.aka.nice at gmail.com 
>> <mailto:nicolas.cellier.aka.nice at gmail.com>> wrote:
>>     Sorry for the high level of noise...
>>     I profited by the low traffic to apply Eliot mechanised tool (
>>     http://www.mirandabanda.org/cogblog/2008/11/14/mechanised-modifications-and-miscellaneous-measurements
>>     )
>>     + own manual changes to remove as much writes as possible (in a short
>>     time frame) to remote (external scope) temporaries from within a
>>     closure.
>>     This should fast up a little bit the image (probably not that much
>>     until Cog is available).
>>     We shall now take the habit of declaring temps in inner scope
>>     possible
>>     and avoid writing in outer temps if possible.
>>     By now, the cosmetic changes has at least a virtue of serving as
>>     examples...
>> This is not purely cosmetic.  Block-local temps are more efficient 
>> than method-level temps assigned inside blocks.  The latter are 
>> indirect temps and cost more to access and cause blocks that use them 
>> to cost more to create.
> Playing devil's advocate, this is surely something that the compiler 
> could optimize away.
> (not actually advocating, just sayin')
> Cheers,
> Josh

I don't think that would be a good thing. It is true that if the temp is 
used only inside the block it doesn't matter. But that leads to sharing 
temps between several blocks, and that has different semantics. The 
compiler can know that (and act accordingly), but I think it is better 
for the programmer to know it!

>>     Cheers
>>     Nicolas

Juan Vuletich

More information about the Squeak-dev mailing list