[Bioperl-l] First commit of Bio::Structure objects

Kris Boulez Kris.Boulez@algonomics.com
Fri, 16 Nov 2001 22:39:23 +0100


Quoting Chris Mungall (cjm@fruitfly.bdgp.berkeley.edu):
> 
> > If the assumption is, that if an object is destroyed all its children
> > (everything underneath it) are destroyed, this should be doable.
> 
> unfortunately it's a bit trickier than that; it's a while since I thought
> about all this (the last time I did it made my head hurt), but I'm pretty
> sure that you have to also force the client code to explicitly free the
> objects once they are no longer in use, a la C coding. This is a bit of a
> burden for the potential users of your objects.
> 
I've just commited my (perhaps to simple) attempt at solving this:

- if your DESTROY is called, call all your childrens DESTROY
   (this will continue untill the bottom)
- clear the references to your children.

The problem I can see with this if someone (in the client) has a
reference to any of your children outside of the scope you're now
leaving. I suspect most of this can be solved by also removing the
children->parent references.
I'll play with it a bit and try some pathological test cases over the
weekend. And read a bit in "Design Patterns", it's laying on my desk
anyway.

Kris,
-- 
Kris Boulez 				Tel: +32-9-241.11.00
AlgoNomics NV 				Fax: +32-9-241.11.02
Technologiepark 4 			email: kris.boulez@algonomics.com
B 9052 Zwijnaarde 			http://www.algonomics.com/