Skip to content

Instantly share code, notes, and snippets.

@ronaldxs
Last active March 13, 2018 11:27
Show Gist options
  • Save ronaldxs/5303df1f7764fc2b57b588de6d38e56f to your computer and use it in GitHub Desktop.
Save ronaldxs/5303df1f7764fc2b57b588de6d38e56f to your computer and use it in GitHub Desktop.
Perl6 hangs on Proxy referring to self
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