Created
May 3, 2015 10:29
-
-
Save anonymous/08896f0615a976d6caa1 to your computer and use it in GitHub Desktop.
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
multi trait_mod:<will>(Attribute:D $attr, $block, :$lazy!) { | |
$attr does role { | |
method compose(|) { | |
callsame(); | |
$attr.package.^method_table{$attr.name.substr(2)}.wrap(-> \self { | |
callsame() // $attr.set_value(self, $block()) | |
}); | |
} | |
} | |
} | |
class A { | |
has $.a will lazy { say 'omg now'; 42 } | |
} | |
my $a = A.new; | |
say 'not yet'; | |
say $a.a; | |
say $a.a; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment