Matt Sergeant <[EMAIL PROTECTED]> writes:
> Here's how XML::XPath 0.50 does circular refs with automatic garbage
> collection...
For reference, Data::Grove::Parent in libxml-perl (superclass of
XML::Grove) also implements a no-circular refs technique. It returns
a proxy object to users that includes a parent reference and a
reference to it's underlying node. Whenever an array or node is
returned, it instead returns a new proxy.
User sees: Real tree:
Parent Proxy ------> Node
^ |
| |
| v
Child Proxy ------> Child
Because of the way this works, users can use the real tree directly if
they don't need parent references, or use Data::Grove::Parent (with a
performance penalty) if they do.
This module is broken at the moment because it's implemented using
tied arrays and hashes and I've yet to find a good strategy for
keeping a reference to the parent's tied object (not the underlying
object, which is passed to all tie handlers).
My proposal for a new underlying data structure, implemented in C/XS,
would probably use a simpler technique.
-- Ken
---
You are currently subscribed to perl-xml as: [[email protected]]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]