Skip to content

Instantly share code, notes, and snippets.

@masak
Created March 5, 2010 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save masak/323269 to your computer and use it in GitHub Desktop.
Save masak/323269 to your computer and use it in GitHub Desktop.
macro my-if($/) is parsed(
rule {
<cond=EXPR> <iftrue=block>
['else' <iffalse=block>]?
}
) {
quasi {
{{{$<cond>.ast}}}
?? {{{$<iftrue>.ast}}}
!! {{{$<iffalse>.ast}}}
}
}
my-if $ticket === $winner {
say 'You won the lottery! OMG!';
}
else {
say 'Hm, no prize today...';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment