Skip to content

Instantly share code, notes, and snippets.

@masak

masak/example.p6 Secret

Last active August 29, 2015 14:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save masak/0bd3f74fc46d0330dc01 to your computer and use it in GitHub Desktop.
A hypothetical use of "walkros", macros that don't fire on a call but rather on a code pattern
intercept (Q::Infix::Add $op) {
quasi {
{{{ $op.right }}} + {{{ $op.left }}} ~ ", lol" # let's ignore the possible infinite regress from defining + with +
}
}
say 40 + 2; # '42, lol'
sub pause {}
intercept (Q::Sub $sub where { #`[the sub has a trait "is cps"; handwave] }) {
#`[ we split the sub up and do lots of funky things to it ]
}
sub foo() is cps {
loop {
say "one";
pause;
say "two";
pause;
}
}
foo(); # 'one'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment