Hi all! After merging XML-Grammar-Fiction and XML-Grammar-Screenplay, I have accumulated several questions about Moose, so I'd post each one in a separate post to keep each thread single-topic. (I hope it's OK.)
The first one is how to implement a Class::Std/Perl 6-like walkmeth: * http://blog.gmane.org/gmane.comp.lang.perl.qotw.discuss/month=20070701 * http://search.cpan.org/perldoc?Class::Std (search for CUMULATIVE). What it does is that in each class out of the various inheritance tree of the module, there is a method, and one accumulates their results so if: [pseudo-code] package Base1; sub a1 { return [qw(foo)]; } package Base2; sub a1 { return [qw(bar)]; } package Class; extends('Base1', 'Base2'); sub a1 { return [qw(quux)]; } [/p-code] Then accumulating a1 will yield [qw(foo bar quux)]. I've implemented something similar in Test-Run: http://svn.berlios.de/svnroot/repos/web-cpan/Test-Harness- NG/trunk/modules/Test-Run/lib/Test/Run/Base.pm (short URL - http://xrl.us/bhjhgt ). Quoting from it: [code] sub accum_array { my ($self, $args) = @_; my $method_name = $args->{method}; # my $class = ((ref($self) eq "") ? $self : ref($self)); my @results; foreach my $isa_class ( $self->meta->find_all_methods_by_name($method_name) ) { my $body = $isa_class->{code}->body(); push @results, @{ $self->$body() }; } return \...@results; } [/code] My question is: is there a better way to do it using Moose? (Or one of the MooseX modules?) Instead, should I implement my own private logic or create a new MooseX module? Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ http://www.shlomifish.org/humour/ways_to_do_it.html God considered inflicting XSLT as the tenth plague of Egypt, but then decided against it because he thought it would be too evil. Please reply to list if it's a mailing list post - http://shlom.in/reply .