Re: [RFC] Combined Comparison (Spaceship) Operator

From: Date: Fri, 23 Jan 2015 00:24:25 +0000
Subject: Re: [RFC] Combined Comparison (Spaceship) Operator
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi Yasuo,

> On 23 Jan 2015, at 00:16, Yasuo Ohgaki <[email protected]> wrote:
> 
> Hi all,
> 
> On Fri, Jan 23, 2015 at 7:48 AM, Larry Garfield <[email protected]>
> wrote:
> 
>> The examples say nothing about mixing types, though.  Eg, what would these
>> return:
>> 
>> return 0 <=> "0"
>> 
>> return "" <=> 0
>> 
>> return 1 <=> [1, 2, 3]
>> 
>> Ignoring object property names and going by the order of the property
>> definition seems like asking for trouble, too.
>> 
> 
> It should be the same as '===', IMO.
> Only the same type should return 0.
> Object has the same id should return 0.
> Arrays would be matter of discussion.

Having it be the same as === would be inconsistent with our existing sorting and comparison
behaviour, so I don’t think it should be changed. If we made it strict like that, we’d also have
to define a strict < and > as well, otherwise we have a problem, because in some cases ($x !==
$y && !($x < $y) && !($x > $y)) is TRUE.

Thanks.

--
Andrea Faulds
http://ajf.me/






Thread (30 messages)