Dominant Macros
marcioAlmada opened this issue · 1 comments
marcioAlmada commented
Currently, by default, a macro backtracks if it's pattern is not fulfilled. But in many cases it would be useful to prevent backtracking after a given entry point is reached.
The idea is to use a single ·
(middle dot) to denote a "point of no return" in a macro pattern, as in:
macro {
unless · (···expression) {
···body
}
} >> {
if (! (···expression)) {
···body
}
}
So any wrong usage of the macro after the arbitrary entry point would throw some variant of syntax error:
unless ($x === 1);
// Unexpected ';' on line 1, expected '{'
I'm still unsure if this is a reasonable way to implement dominant macros. Maybe "dominant" should be the default behavior and a tag to allow backtracking (macro ·allow_backtrack {...} >> {...}
) could be a better option.
marcioAlmada commented
✅