Skip to content

Instantly share code, notes, and snippets.

Created March 24, 2015 16:44
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 anonymous/2fafaef93a43c3cb2dbe to your computer and use it in GitHub Desktop.
Save anonymous/2fafaef93a43c3cb2dbe to your computer and use it in GitHub Desktop.
class GenericService {
only sub infix:<cmp> ($a,$b) { $*CMP($a,$b) }
method lifter1 () {
my $*CMP = CALLER::LEXICAL::{ '&infix:<cmp>' };
lifter2;
}
sub lifter2 () {
say "Lifted: { 42 cmp "Life, The Universe, and Everything" }";
}
}
{
multi sub infix:<cmp>(42, "Life, The Universe, and Everything") { Order::Same }
{{{{{
sub trylift () {
nonlifter;
GenericService.lifter1;
}
trylift;
}}}}}
}
sub nonlifter () {
say "Normal: { 42 cmp "Life, The Universe, and Everything" }";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment