Instantly share code, notes, and snippets.

Embed
What would you like to do?
Perl6 hangs on Proxy referring to self
class c {
sub double() is rw {
my $count = 0;
my $storage = 0;
Proxy.new(
FETCH => method () { say $count++; say self.WHAT if $count <= 3; $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