On Tue, 3 Feb 2009, Otto Hirr wrote:
Going back over recipe3, I believe that the:
1 before 'right', 'left' =>sub {
2 my( $self, $tree ) = @_;
3 $tree->parent( $self ) if defined $tree;
4 }
is not needed and line 3 is dead code...
Try rewriting with:
3a if( defined $tree ){
3b $tree->parent( $self );
3c }
and place a break point on 3b. It is never called.
That is because you would have to have an explicit param,
like $t1->left( $t2 ). That would result in the following:
$t2->parent( $t1 )
which seems wrong.
No, that's right. If we set a child node for a tree (its left or right),
we also want to make sure the child has the correct parent.
The recipe states:
'They will not install the parental relationships that we need.'
but they do, as demonstrated by the test code, there are parent,
left, and right nodes.
It seems to me that the above result, ie: $t2->parent( $t1 )
winds up ripping out the node from the tree.
I'm not sure what you think is going on, but when I look at the code it
makes sense to me.
-dave
/*============================================================
http://VegGuide.org http://blog.urth.org
Your guide to all that's veg House Absolute(ly Pointless)
============================================================*/