Re: [RFC][DISCUSSION] throw expression
| From: | Andrea Faulds | Date: | Wed, 25 Mar 2020 19:12:11 +0000 |
| Subject: | Re: [RFC][DISCUSSION] throw expression | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-109310@lists.php.net to get a copy of this message | ||
Hi Dan,
Dan Ackroyd wrote:
Regarding the example: $condition || throw new Exception('$condition must be truthy') && $condition2 || throw new Exception('$condition2 must be truthy'); The "Deprecate left-associative ternary operator"* RFC made it so that parentheses are required when ternary operators are nested in complicated statements. Would a similar requirement for parentheses around complicated throw expressions be a suitable solution to avoid people being surprised by the behaviour? cheers Dan Ack * https://wiki.php.net/rfc/ternary_associativityIs there a strong reason to require parentheses? I would think we can just give
throw an appropriate precedence so that expressions like the above do what is desired — and then if you wanted to do something unusual, you would have to add parentheses anyway.
Regards,
Andrea