lpeg manual mentioned P(true) and P(false). why are these needed ?
x true = x
true x = x
so P(true) will always be optimized away.
At first, I thought P(false) is to retain captures, then switched to alternative.
(lpeg codes A with captures ...) * P(false) + (lpeg codes B ...)
But it does not. All the captures are gone.
Above just optimized to (lpeb codes B ...)
The only reason lpeg does not do this optimization is due to its
match-time-capture function.
I cannot think of 1 case where P(boolean) is needed.
May that were the reason lpeg re doesn't have them as variables.
x true = x
true x = x
so P(true) will always be optimized away.
At first, I thought P(false) is to retain captures, then switched to alternative.
(lpeg codes A with captures ...) * P(false) + (lpeg codes B ...)
But it does not. All the captures are gone.
Above just optimized to (lpeb codes B ...)
The only reason lpeg does not do this optimization is due to its
match-time-capture function.
I cannot think of 1 case where P(boolean) is needed.
May that were the reason lpeg re doesn't have them as variables.