Re: [RFC][POLL] Switch expression
| From: | Ilija Tovilo | Date: | Wed, 01 Apr 2020 08:37:59 +0000 |
| Subject: | Re: [RFC][POLL] Switch expression | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-109493@lists.php.net to get a copy of this message | ||
Hi internals
After Levis email yesterday we discussed his suggestions in private. I
did some investigation and did find a way to reuse the current switch
syntax. The main problem of the ambiguity was the empty switch
statement vs expression:
```
// Could be a switch expression or a switch statement with an empty
statement (;)
switch ($x) {};
```
Disallowing the switch expression to be empty solves the ambiguity.
```
// This code throws a parser error
$x = switch ($y) {};
```
It's not optimal but everything else will require significant changes
in the grammar and have other downsides. I updated the RFC
accordingly.
Ilija