Created
June 25, 2014 08:07
-
-
Save anonymous/1fab6c3c028192d89b31 to your computer and use it in GitHub Desktop.
perl 6 trait problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
role SomeTrait { | |
method apply_handles($attr: Mu $pkg) { | |
my $name = $attr.name; | |
my $accessor = $name.subst(/^../, ''); | |
$pkg.HOW.find_method($pkg, $accessor).wrap(-> $obj, |args { | |
say "$name accessor"; | |
callsame; | |
}); | |
} | |
} | |
multi trait_mod:<is>(Attribute $var, :$wtf!) { | |
$var.set_rw(); | |
$var does SomeTrait; | |
} | |
class foo { | |
has $.x is wtf; | |
} | |
my $foo = foo.new; | |
$foo.x = 'bar'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment