Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

JonathanWorthington (6049)

  (email not shown publicly)
Wednesday April 09, 2008
05:23 PM

Delegation With 'handles'

[ #36116 ]

On the train over to Stockholm after the hackathon and on the plane back to Spain a day later, I implemented various cases of 'handles' (not all of them, since the wildcard ones are trickier - they will get done probably along with a whole load of other work on attributes that needs doing). The 'handles' trait verb is the thingy that lets you auto-generate methods that delegate to a methods on an attribute. Here's some examples of what you can do with this:

class Bar { method a { say "a" }; method b { say "b" } }
class Foo1 { has $x handles 'a' } # one method
my $test = =>; $test.a()
class Foo2 { has $x handles <a b> } # several
my $test = =>; $test.a(); $test.b()
class Foo3 { has $x handles :mya('a') } # rename one
my $test = =>; $test.mya();
class Foo4 { has $x handles (:mya('a'), :myb('b')) } # rename many
my $test = =>; $test.mya(); $test.myb();

So, that's another small piece of the Perl 6 implementation puzzle put into place.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.