Last active
March 13, 2018 11:27
-
-
Save ronaldxs/5303df1f7764fc2b57b588de6d38e56f to your computer and use it in GitHub Desktop.
Perl6 hangs on Proxy referring to self
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
class c { | |
sub double() is rw { | |
my $storage = 0; | |
Proxy.new( | |
FETCH => method () { say self.WHAT; $storage * 2 }, | |
STORE => method ($new) { $storage = $new }, | |
) | |
} | |
method m { | |
my $doubled := double(); | |
$doubled = 4; | |
say $doubled; # OUTPUT: «8» | |
} | |
} | |
c.m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment