Re: [VOTE] Saner string to number comparison

php.internals

Benjamin Morel

6 years ago
Thanks for this RFC, Nikita! This is definitely a step in the right direction, and I can only hope it will pass. One question:
> (...) by using a number comparison only if the string is actually numeric. Otherwise the number is converted into a string, and a string comparison is performed.
Is there a reason to perform another comparison as a string, when the string is not numeric? I can’t think of a case where the string comparison would match. - Benjamin

Nikita Popov

6 years ago
On Fri, Jul 17, 2020 at 6:29 PM Benjamin Morel <benjamin.morel@gmail.com> wrote:
> Thanks for this RFC, Nikita! This is definitely a step in the right > direction, and I can only hope it will pass. > > One question: > > > (...) by using a number comparison only if the string is actually > numeric. *Otherwise the number is converted into a string, and a string > comparison is performed.* > > Is there a reason to perform another comparison as a string, when the > string is not numeric? I can’t think of a case where the string comparison > would match. >
Comparisons are not just about equality, they are also about ordering. Nikita