In Perl 5 C<for> is quite natural for iterating over lists and arrays. C<while> is preferred for filehandles. With lazy evaluation this difference has been eliminated in Perl 6 so that while still TMTOWTDI (TAEMWTDI!) this kind of iterations will be more consistent.

But in Perl 5 to "navigate" complex structures one needs ad-hoc solutions. I wonder if something is planned in Perl 6 as a means to do that through a syntactically convenient construct with ad-hoc-isms pluggable in in the form of suitable hooks (e.g. .on_node( { code; ... } ), etc.) that would work in most cases.

Please do not ask me what I have in mind, for I'm not really sure. I know in advance that suitable modules may be written instead but I would like a single builtin keyword. And I'd like to hear the opinion of the Knowledgeable Ones(TM) here.

Suppose I want to navigate a tree and print out info contained in each of its leaves along with info gathered from the position in the tree of the list itself? Can I do it in a "universal" manner as hinted above that would work for other situations as well?

PS: By "complex structure" here I mean a [AH]o[AH]o[AH]... or somesuch with arbitrary nesting levels. Objects would do if they had sufficient navigational info (e.g. parent(), next(), havechild(), etc.) i.e. if they conformed to some probably not yet established interface.


Michele
--
I wish Sun would sort their versioning out
and have their marketing department shot.
- "tomazos" in PerlMonks.

Reply via email to