Re: [RFC] Strict operators directive
| From: | Christian Schneider | Date: | Wed, 26 Jun 2019 09:22:05 +0000 |
| Subject: | Re: [RFC] Strict operators directive | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-106068@lists.php.net to get a copy of this message | ||
Am 26.06.2019 um 11:09 schrieb Benjamin Morel <benjamin.morel@gmail.com>:
>
>> "120" > "99.9"; // TypeError
>> Anything else will bring confusion.
>
> Not sure about this, you can do it the JS way: if both operands are
> strings, then it behaves like strcmp():
>
> "23" > "4"; // false
> "23" > "221"; // true
>
> I'm not saying that we should do it, but this would not be confusing to me
> at all.
With the proposed change both
"23" > "4" === true # Current behaviour
and
"23" > "4" === false # New strict behaviour
could be the case depending on a declaration somewhere else in the source code.
That's the confusion Claude and I were talking about: You cannot be sure what a very simple
line of code does.
- Chris