Last active
December 25, 2015 23:49
-
-
Save arnsholt/7059777 to your computer and use it in GitHub Desktop.
Rakudo/JVM rolw mixin shenanigans
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
my role Foo { | |
has $!setup; | |
method postcircumfix:<( )>($args) { | |
#say self.?bar // 'not what we want'; | |
if nqp::can(self, 'bar') { say self.bar } | |
else { say 'no what we want' } | |
} | |
} | |
my role Bar[Str $name] { | |
method bar() { $name } | |
} | |
multi trait_mod:<is>(Routine $r, :$foo!) { | |
say $r.^name; | |
$r does Foo; | |
say $r.^name; | |
} | |
multi trait_mod:<is>(Routine $r, :$bar!) { | |
say $r.^name; | |
$r does Bar[$bar]; | |
say $r.^name; | |
} | |
sub test() is foo is bar('what we want') { * } | |
test(); | |
say &test.^name; | |
# vim:ft=perl6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment