develooper Front page | perl.perl5.porters | Postings from March 2000

Re: [p5pod] Pod::InputObjects patch for plain refs

Thread Previous
Brad Appleton
March 7, 2000 09:38
Re: [p5pod] Pod::InputObjects patch for plain refs
Message ID:
On Tue, Mar 07, 2000 at 12:55:21PM +0000, M.J.T. Guy wrote:
> While correcting the logic, why not get rid of the dodgy test entirely?
>          if (UNIVERSAL::isa($_, 'Pod::InteriorSequence') or
>              UNIVERSAL::can($_, 'nested')) {

That would break things in a subtle yet highly undesirable way.

> My rule of thumb is that if you're doing an explicit equality test
> on the result of ref(), there's almost certainly a better way.

Well - that usually my rule of thumb too. Problem is there are exceptions
and I believe this is one of them. It has to do with garbage collection
and I certainly wish there was a better way, but I'm not convinced that
there is at present. (I'd be happy to be wrong about this).

For starters, I really and truly do need to make a special exception for
things that are InteriorSequences are subclasses thereof, because there
are certain assumptions that allows me to make, but which I don't want
to require of all clients.

At the heart of the issue is that I have a tree-like structure with
upward (parent) pointers as well as child pointers, and I need to make
sure that things get garbage collected appropriately even though there
are cycles in the graph that would otherwise stop Perl from freeing
the resources. So its the case that not quite everything has a parent
pointer, just everything that wouldn't stop the root of the tree from 
having its ref count goto zero when it goes out of use by the client.

I admit its very ugly - it just happen to be the least ugly way that I
could get it to do what I need.

Brad Appleton <>
  "And miles to go before I sleep." -- Robert Frost

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About