Dave Whipp dave-at-whipp.name |Perl 6| wrote:
>
> 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) }

...

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.


The |$args does include the $self as the first argument. The syntax tail.wag(|$args) will start with the implied tail as the first argument, then interpolate the rest of the args including its first one.

Unless the receiver is in a different slot in the Capture, but the binding rules don't explain that, only give a hint that you can use Capture in scalar context to get it. If that's the case, then the one on the right overrides, and you will find the method in tail's class called with the original object as self, which just doesn't make sense.

So, I concur that the description of delegation still needs work, and is open for ideas on how to make it work right. (Unless Larry knows in his head and just didn't explain it fully)

--John

Reply via email to