I noted Jonathan Worthington's work implementing the "handles" trait for
delegation through attributes, and was a bit surprised to see that it is
defined (S12/delegation) to use strings instead of method signatures --
I had thought that perl6 was attempting to be symbolic in places where
perl5 uses strings for its type system.
Looking at the S12 text:
> Delegation lets you pretend that some other object's methods are your
> own. Delegation is specified by a handles trait verb with an argument
> specifying one or more method names that the current object and the
> delegated object will have in common:
>
> has $tail handles 'wag';
>
> Since the method name (but nothing else) is known at class
> construction time, the following .wag method is autogenerated for you:
>
> method wag (|$args) { $!tail.wag(|$args) }
it occurs to me that one might want to say:
class Foo {
has $a handles &do_it(Str);
has $b handles &do_it(Int);
}
Would it cause problems to use method signatures in this context?
Another thing that might be nice (maybe not a perl 6.0.0 feature, but
something that it shouldn't be too difficult to add later) would be a
way to tell the delegation to pass "self" as an extra arg to the
delegate method. Obviously at some point one has to say "just write the
delatation code yourself", but I think that it's a common pattern to
write { method do_it { $!a.do_it(self) } }.