On Sun, October 3, 2010 6:18 pm, Stas Malyshev wrote:
>> $a = new stdclass;
>> $a->prop = null;
>> $b = new stdclass;
>> $b->prop2 = null;
>>
>> var_dump($a>  $b); //false
>> var_dump($a == $b); //false
>> var_dump($b>  $a); //false
>
> That's because there's no total ordering of generic objects that can
> make sense. Only very specific objects - such as ones representing
> numeric qualities or having numeric properties - can be ordered, most
> of
> objects are unordered. And comparing objects with scalars
> automagically
> might bring a lot of surprises as nobody really expects $a == $b and
> $b
> == $a to be different now.

If you make == not reflexive, I'd be pretty cranky... :-)

HOWEVER, here's an idea from left field...

If PHP is comparing OBJECTS and cannot discern an ordering, perhaps
returning NULL instead of FALSE would make sense.

I have NO IDEA if this is do-able, sensible, or reasonable...

It just struck me that when PHP doesn't "know" $a < $b should be
TRUE/FALSE, returning NULL instead would be a "reasonable" course of
action, from this naive scripter's POV.

-- 
brain cancer update:
http://richardlynch.blogspot.com/search/label/brain%20tumor
Donate:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to