> On 16 Jan 2015, at 1:25 , Johan Fabry <jfa...@dcc.uchile.cl> wrote: > > > As I’ve been asked, I’ll clarify a bit more. When I said it worked before I > was actually wrong because I had forgotten to remove some alternative cleanup > code (the alternative works but it’s like using a cannon to kill a fly). > > This is part of the interpreter for Live Robot Programming that Miguel and I > are working on. As part of that we need a data structure that holds scopes, > for variables but also for other things. It turns out that for the variables > part we can map rather nicely to classes, which gives us a bunch of > advantages. So for each scope I generate a class. The scope keeps that class > in a ‘vars’ instance variable (there are never any instances of these classes > BTW). When the scope is garbage collected I want to remove the class from the > system. So I put #finalize in the scope with the idea to remove the class, > but it turns out that ‘vars’ is always nil. So in the end it did not work out > ...
You're probably registering the scope for finalization before setting the vars insvar? The shadow copy is made at the point of registration, so any subsequent assignments to the scope's instvars is not accounted for. Cheers, Henry