Mark Stosberg wrote:
In the Objects chapter, a WALK pseudo-class is spec'ed for using
when calling sets of methods:

  http://feather.perl6.nl/syn/S12.html#Calling_sets_of_methods

These are the arguments listed that can be used with WALK:

    :canonical      # canonical dispatch order
    :ascendant      # most-derived first, like destruction order
    :descendant     # least-derived first, like construction order
    :preorder       # like Perl 5 dispatch
    :breadth        # like multi dispatch

First, it would be nice if the comments "like Perl 5" and "like multi
dispatch" could be expanded, if only to provide references to their
complete specs. Also, if "canonical" means something besides "I don't
care", it would be nice to have a reference for that, too.

I think Class::C3 on CPAN describes and implements the Perl 6 dispatch
algorithm in Perl 5.  I don't know if it's in the Synopses, etc.

My concern for the moment is clarification how these options can be
combined. Clearly, combining ":ascendant" and ":descendant" doesn't make
sense.

But, I assume a "self.*meth" call can work along both the inheritance
axis and the multi method access.

Therefore, it seems fair to combine one option that affects each axis.

Wouldn't ":breadth" just be the breadth first order of the same set
of methods?  Mentioning multi dispatch kind of confusing...

So I think the permitted combinations are:

One sorting adverb (defaulting to :canonical):
    :canonical, :ascendant, :descendant, :preorder, :breadth

Some number of filtering adverbs:
    :super              # only immediate parent classes
    :method<name>       # only classes containing method declaration
    :omit(Selector)     # only classes that don't match selector
    :include(Selector)  # only classes that match selector

There does seems to be a bit of slack in this section of the Synopsis,
particularly with regard to multi methods.  Perhaps I'm just reading
out of context.

As a "use case", in CGI::Application we traverse classes ":ascendant"
but then execute what would be "multi methods" in the order they are
defined, which sounds like perhaps ":preorder" to me.

I'd like to be able to access the list of methods returned by
the WALK traversal. Perhaps it is:

  @methods = $object.*WALK::can('meth');

You may want to combine method calls in other ways, with
a short circuiting && or || for example.  "last METHOD" could be
used to short-circuit but then the methods can't be composed
using with different logic.

Maybe some of the adverbs above could be replace by a grep on the
method list.  Although, a) short-hand++  b) the grep is dynamic
and the adverbs are declarative.

Brad

--
 There are two things that will blemish a retainer, these are riches and
 honor. But if one remains in strained circumstances he will not be
 marred.                         -- Hagakure http://bereft.net/hagakure/

Reply via email to