On 25/08/2024 18:12, Rowan Tommins [IMSoP] wrote:
For instance, rather than adding "default" to the "expr" rule in the
grammar, and then restricting it at compile-time, maybe we add a new
grammar rule "expr_with_default", usable only in expressions and with
a very limited set of productions.
Like the original commit
<https://github.com/php/php-src/pull/15437/commits/fd7ac5f83b8282227235095843cb73e9d66b0717#diff-3e6742a9069b5717cf961c9d6b2aefbd1c730869d8a58123b1b5f3bc3e9082fcR1329>?
Yeah, we did that.
Just because it's easy to implement a feature a particular way,
doesn't mean that's necessarily the right way.
With respect, you do not know what you're talking about here. The
original approach was to start manually whitelisting each expression
grammar I thought made sense. THAT was the easiest way because both
myself an Ilija failed in our first attempts to expand the grammar to
support default as a general expression, and not for lack of trying. It
took a Bison grammar expert to drop a patch that certainly wowed me,
because hitherto I wasn't even certain it was possible, mainly because
of the conflicts with `match` (but also `switch` to some extent). Aside,
with respect to match, there is still an unresolved case and the RFC
needs updating with the semantics we want to enforce there. So we
pursued default as an expression not because it was easy, but despite
the fact that it was hard, because it was precisely what we wanted to do.
I apologise for coming on strong, but I put a lot of effort into this,
so I take exception to the implication that anyone involved took the
easy way out to arrive at this (our best) solution.
Kind regards,
Bilge