On Sun, Mar 22, 2020 at 5:17 PM Ilija Tovilo <ilija.tov...@me.com> wrote:

> Hi everybody! I hope you’re doing well.
>
>
>
> Due to the modest feedback I’d like to move the throw expression RFC to
> “under discussion”.
>
> https://wiki.php.net/rfc/throw_expression
>
>
>
> In short, the RFC proposes to convert the throw statement into an
> expression to make it usable in arrow functions, the coalesce operator, as
> well as the ternary/elvis operator.
>
> If you have any feedback, concerns, or if you want to express your
> interest or lack thereof, let me know!
>

Looks like a reasonable change to me. Maybe interesting to compare with the
ECMAScript and C# proposals you reference:

The ECMAScript proposal (https://tc39.es/proposal-throw-expressions/)
defines the throw expression as a very high precedence operator, rather
than a low precedence one. There's discussion on that in
https://github.com/tc39/proposal-throw-expressions/issues/10. Reading that
thread, it seems like nobody actually wants the high precedence version,
but there are some ECMAScript-specific issues with low precedence, because
of conflicts with comma expressions. Thankfully that doesn't apply to us.

The C# proposal (
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.0/throw-expression)
limits the use of throw expressions to specific context only (in short
lambdas and on the right hand side of ?: and ??). I'm personally not a fan
of that, unless there's a technical motivation for that. If it's just about
enforcing coding style, there's already plenty of weird expressions you can
write right now. I don't want to add special cases to the language
specification to enforce someone's style preferences.

> The "Deprecate left-associative ternary operator"* RFC made it so that
> parentheses are required when ternary operators are nested in
> complicated statements.

I should probably explicitly say here that the parentheses are required not
because I think it is a good idea to require them, but to avoid changing
the interpretation of an expression from one version to the next. Given
that we did end up changing the precedence of the "." operator (rather than
requiring parentheses), this choice is somewhat dubious now, and it would
have been better to simply change the interpretation of the ternary in PHP
8 as well.

Regards,
Nikita

Reply via email to