develooper Front page | perl.perl6.language | Postings from October 2008

A question about arrays

Thread Next
From:
Timothy S. Nelson
Date:
October 15, 2008 21:37
Subject:
A question about arrays
Message ID:
alpine.LRH.1.10.0810161444130.12043@gwalcmai.nelson.org.au
 	Hi all.  I'm working on the code for trees that I keep talking about, 
and I have code that somewhat resembles the following:

role	Tree::Node does Array {
 	has Tree::Node @!children handles <Array List Container>;
}

 	The intent of this code is that, if you treat the Tree::Node as an 
array, you're operating on its children.  I'm sure there are obvious bugs in 
that code that I'd be happy to hear about, but my question at the moment is, I 
want to be able to intercept calls that put things into the array and pull 
them out, and perform code at that time.  For example, I'd like it if

$node = Tree::Node->new();
$othernode = Tree::Node->new();
$node[0] = $othernode;

 	...would allow me to operate on $othernode, so that I could ensure 
that they belong to the same tree, for example.  Is there a way I can do that?

 	Thanks,


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

----BEGIN GEEK CODE BLOCK----
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-
-----END GEEK CODE BLOCK-----


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About