[gambit-list] References between 'foreign' objects.

Marc Feeley feeley at iro.umontreal.ca
Sat Mar 24 15:06:23 EDT 2012


On 2012-03-24, at 12:31 PM, Estevo wrote:

> I still have the somewhat converse problem: when Gambit loses sight of your last Scheme reference to a "parent" struct, it will clean it up even if there are Scheme references to "child" structs.
> 
> I would like to somehow make a Scheme reference to the "parent" struct from the "child" structs, so that children will keep the parent alive as long as they are around.  This reference needs not be visible from Scheme; it's only to help the garbage collector do the right thing.
> 
> I can think of a couple ways to do this, but they either complicate my macro considerably, or make things more cumbersome for the user -- or both.  I'm asking the list just in case I'm missing an easy way to create these links.
> 

I haven't looked at the details, but wouldn't a doubly-linked tree work?  In other words, the parent has a list of children, and each child has a "parent" pointer.  Then, whichever node of the tree is being referenced, all of the nodes of the tree will be maintained by the GC.

Marc




More information about the Gambit-list mailing list