Re: Strict switch statements

From: Date: Fri, 15 Jun 2018 08:40:27 +0000
Subject: Re: Strict switch statements
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-102272@lists.php.net to get a copy of this message
On 14 June 2018 at 23:15, Stanislav Malyshev <smalyshev@gmail.com> wrote: > Hi! > > > Would both be more apparent as to its meaning and leave the door open > > for other uses. Though at that point, tbqh, I think `switch ($a) use > > (===) {...}` gives better visual isolation. > > I don't think we should reuse the use() thing for third purpose when > we're already using it for two. I imagine with new parser logic we > should not be as restricted in syntax choices as we've been before? So > being a bit more explicit than "use(===)", which would be a bit of a > head-scratcher for a casual PHP user. Something like "strict switch" at > least gives a person something to ask about - what is "strict switch" > exactly? But "use(===)" would be harder to read and harder to look up > online. > As I've said before, I think precisely the opposite: === immediately means "strict comparison" to anyone who knows PHP, but "strict switch" could mean any number of restrictions: strict comparisons, no implicit fall-through of cases, no duplicate cases, etc, etc If it's the keyword reuse and punctuation that are an issue, what about just picking a different word, and leaving out the parens: switch ($foo) with === { case 42: blah(); break; case '42': blerg(); break; } Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#102272) next »