Skip to content

Instantly share code, notes, and snippets.

Created June 25, 2014 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1fab6c3c028192d89b31 to your computer and use it in GitHub Desktop.
Save anonymous/1fab6c3c028192d89b31 to your computer and use it in GitHub Desktop.
perl 6 trait problem
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