Re: Little switch improvement: get the used variable
| From: | Rowan Collins | Date: | Thu, 25 Sep 2014 10:31:21 +0000 |
| Subject: | Re: Little switch improvement: get the used variable | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-77621@lists.php.net to get a copy of this message | ||
Christian Stoller wrote (on 25/09/2014):
Sorry, I was talking about this bit:Am I missing something equally obvious there? Or just, it doesn'tinterest people much as an idea? Why should one add a new operator in that context if it is already possible with assigments as expressions? This makes the language more complex without getting any improvement.
Currently, switch always uses a "loose" comparison (==), so cannot distinguish between "case 3" and "case 3.0". Occasionally, it would be nice to switch on a strict comparison (===); but then I thought, why stop there? What if you could use switch with any comparison operator? My idea is to give the switch() statement an optional "use" clause (since that's an existing keyword) containing a single comparison operatorSee my earlier e-mail for examples and further details. Maybe I should have given it its own thread so it was more visible; the idea has been brewing for a while, I just thought this thread was a convenient place to mention. -- Rowan Collins [IMSoP]