On Dec 20, 2003, at 1:14 PM, NYIMI Jose (BMB) wrote:
http://www.perl.com/pub/a/2002/08/07/proxyobject.html?page=3[..]
Jos�.
worth while Read - thanks!
But back to christopher's query
On Dec 20, 2003, at 11:46 AM, christopher j bottaro wrote:
just for practice, i made a class BinaryTree. its just a blessed reference to[..]
a hash that contains two things: size and root. root gets assigned to a
BinaryTree::Node which is just a bless reference containing: key, value,
left, right.
perl deallocates according to reference counts. so if i want "destory" my
tree structure, i'd have to make sure there are no references to any of the
BinaryTree::Node's, right? something like this...
is your question here about how the Destroy works? and when is it fired?
The demo code is at:
<http://www.wetware.com/drieux/pbl/perlTrick/OO/BinTree/ bin_treeDestroy.plx>
it will generate something like
$VAR1 = bless( {
'size' => 3,
'root' => bless( {
'right' => bless( {
'value' => 3,
'key' => 'b'
}, 'BinaryTree::Node' ),
'value' => 2,
'left' => bless( {
'value' => 1,
'key' => 'a'
}, 'BinaryTree::Node' ),
'key' => 'b1'
}, 'BinaryTree::Node' )
}, 'BinaryTree' );
about To exit it all
tree had 3 elements
Tree: Destory called
Node: with b1 destorying
Node: with b destorying
Node: with a destorying
after it allIt seems to me that without doing any special voodoo in the DESTROY it found the three BinaryTree::Node elements and was able to destroy them.
Your specification for the BinaryTree::Node did NOT seem to have a reference back to the Parent node, and would have been the problem that would have developed your circular reference that is the problem that needs to be addressed.
HTH.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
