Skip to content

Instantly share code, notes, and snippets.

@kl0tl
Last active August 29, 2015 14:02
Show Gist options
  • Save kl0tl/9a98232932ed5a3b8498 to your computer and use it in GitHub Desktop.
Save kl0tl/9a98232932ed5a3b8498 to your computer and use it in GitHub Desktop.
Parens free `until` statement, the opposite of `while`
/*
`until cond {}` is equivalent to `while !(cond) {}`
Brackets are mandatory
The following syntaxes are also valid
`do {} until cond`
`until cond;`
*/
macro until {
rule { $cond:expr { $body ... } } => {
while (!$cond) { $body ... }
}
rule infix { do { $body ... } | $cond:expr } => {
do { $body ... } while (!$cond)
}
rule { $cond:expr ; } => {
while (!$cond);
}
}
export until;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment