Skip to content

Instantly share code, notes, and snippets.

@peschwa
Created February 17, 2015 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peschwa/4fe16e5c5aa2e5b8370c to your computer and use it in GitHub Desktop.
Save peschwa/4fe16e5c5aa2e5b8370c to your computer and use it in GitHub Desktop.
my $cl = { say $/ };
class C {
proto foo(|) {*};
multi method foo(C:U: $cl, $) {
return self.foo($cl)
}
multi method foo(C:U: $cl) {
"b" ~~ /./; my $cds := nqp::getlexcaller('$/'); $cds = $/; $cl()
}
}
C.foo($cl, 1); # prints Nil
say "=" x 10;
proto bar(|) {*};
multi bar($cl, $) {
bar($cl)
}
multi bar($cl) {
"bar" ~~ /./; my $cds := nqp::getlexcaller('$/'); $cds = $/; $cl()
}
bar($cl, 1); # prints 「b」
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment