Re: [RFC] Short-match

From: Date: Mon, 21 Dec 2020 22:21:11 +0000
Subject: Re: [RFC] Short-match
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-112579@lists.php.net to get a copy of this message


> On Dec 16, 2020, at 12:49 PM, Ben Ramsey <ben@benramsey.com> wrote:
> 
>> On Dec 16, 2020, at 10:54, Mike Schinkel <mike@newclarity.net> wrote:
>> 
>> If we allow "switch {...}" to represent  "switch (true){...}" then the
>> value switch compares will be hidden and less obvious to a developer if they are forgetting to
>> consider switch's evaluation behavior. For some people this would increase the WTF factor.
> 
> How does "switch (true){...}" cause less surprise than
> "switch {...}” for loose comparisons? IMO, seeing the boolean value
> true causes more confusion, since it matches any truthy value but the constant value in
> the expression is a bool.

I believe I must have worded it such that you misunderstood what I was writing.

In fact, what you wrote is the point I was trying to get across.  Sorry for my poor phrasing.

-Mike


Thread (29 messages)

« previous php.internals (#112579) next »