[Bese-devel] problem with actions

Drew Crampsie drewc at tech.coop
Tue Aug 2 23:07:06 UTC 2005


Alexander Kjeldaas wrote:
> Drew Crampsie wrote:
> 
>> This is because your implementation is free to re-use the binding of i
>> within the loop, and the <ucw:a is creating a closure over that binding.
>>  consider the following code :
>>
> [...]
> 
> Shouldn't ideally the macro-expansion of display-number take care of 
> this?  Or are there situations where this behaviour is necessary?

How would the macro-expansion find out which lexicals is has to rebind?

This behavior is part of the ANSI specification (not specific to UCW), 
and while i've never found it useful, it is effecient from an 
implementation point-of-view.

Imagine a loop over a large set. If the implementation kept all those
bindings around it would require twice the memory to run the loop, and
then a massive amount of garbage to clean up afterwards (in the normal 
case, where the binding is not closed over). Not an ideal
situation.

drewc





More information about the bese-devel mailing list