Last active
August 29, 2015 14:02
-
-
Save kl0tl/9a98232932ed5a3b8498 to your computer and use it in GitHub Desktop.
Parens free `until` statement, the opposite of `while`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
`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