Re: [RFC] Comparison and conversion inconsistency - need more info
| From: | Yasuo Ohgaki | Date: | Sat, 09 Nov 2013 22:33:57 +0000 |
| Subject: | Re: [RFC] Comparison and conversion inconsistency - need more info | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70069@lists.php.net to get a copy of this message | ||
Hi Stas,
On Sat, Nov 9, 2013 at 5:28 PM, Stas Malyshev <smalyshev@sugarcrm.com>wrote:
> Hi!
>
> > I was surprised that wired min() behavior.
> > The cause of this behavior is in Zend API.
> >
> > https://bugs.php.net/bug.php?id=53104
> >
> > So I've made FRC to discuss/document/fix such behavior.
> >
> > If anyone know such behavior, please let me know so that I can write them
> > in the RFC.
>
> In the engine, null is less than -1. Changing it would be a very
> profound compatibility break, so I do not think it can be done in any
> 5.x version.
>
> Current behavior is described here in detail:
> http://php.net/manual/en/language.operators.comparison.php
>
> Null is the same as false in this case, which is less than any non-false
> value. -1 is a non-false value.
>
My intention is not fix them all, but document them if we are not
going to fix inconsistent behaviors.
For example, string may be converted to int when it seems int/float or hex,
but it's not converted when it seems octal or binary. I think it's not
documented yet. (At least not clearly, is it? Adding octal/binary conversion
is not a good idea. Likewise, -1 should be true.)
I'm wandering whether there are functions like min(). It does not
follow basic comparison/conversion rules. min() behavior is nonsense and
it would be good fixing min() at some point. Not many users will be
affected, IMO.
https://bugs.php.net/bug.php?id=53104
There may be function like min(), but it may not be feasible to change
behavior. If change is not feasible, we may document behavior instead.
If we fix little inconsistencies like this, it would be better fix them all
at once.
Do you know any functions like min()?
Regards,
BTW, typo in s/wired/weird/ in first post :(
--
Yasuo Ohgaki
yohgaki@ohgaki.net