On Thu, 19 Feb 2009, Daniel Ruoso wrote:

Em Qui, 2009-02-19 às 22:57 +1100, Timothy S. Nelson escreveu:
        Interesting.  I'm happy to assume that $root is allowed to be
Undefined, I think.  But let me ask a question; were you to represent an
unrooted tree in a computer, how would you do it so that, if you had to look
around the tree, you could do it?  You'd need some node that was an
entry-point into the tree.  That's the purpose I'm trying to get at here.

Not at all, that is the same as saying that a list must always be
ordered, and that it should have a beggining. Circular Lists are very
well known.

I guess I'm trying to say something slightly different. Let me give an example. If you tried to create a circular list in Perl, with, eg.

class   Node {
        has $nextnode;
        has $data;

...and you got a few, and linked them in a circle, but then got rid of all variables that refer to them, then if I understand correctly, you'd be entirely unable to get the data out again. But given one (or more) variables that points to this list, you'd be able to walk around in it and retrieve all the data.

What I want the Tree role to do is to be a place where we can ensure that at least one of the nodes is referred to.

If you think in a BTree, for instance, you usually don't have a root
node, since a BTree is simply a way to view a list, and you might
receive a node and work only from that context onward. That even applies
for filesystems: what if your process calls (2)chroot? what happens to
the "root" node?

It changes :). So I guess chroot should be replaced with a setter on $Tree.root :).

On the other hand, I have to disagree with masak that it would be an
empty role, because there is indeed one operation that you can always do
in a tree node:

role Tree::Node {
  method List lookup(*%options);

[snipped lookup examples]

Hmm. It seems we're trying to achieve the same things, but you want everything done as parameters to a lookup method, whereas I want everything done as attributes and methods on the node.


| Name: Tim Nelson                 | Because the Creator is,        |
| E-mail: wayl...@wayland.id.au    | I am                           |

Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-

Reply via email to