I don't want to get into a lengthy debate (you have your opinion; I have mine!), but to rebut a couple of specific points:
On 19 February 2015 at 14:19, Levi Morrison <le...@php.net> wrote: > Another issue: it allows comparing an object to non-objects (even > though the stated goal is only to compare two objects of the same > type): This is intentional. The wording in the introduction is probably a little too specific to the object case — I'll fix that. > class MyClass implements Comparable { > private $val = 0; > function compareTo($a) { > return $this->val <=> $a; > } > } > > $int = 10; > $myClass = new MyClass(); > $myClass <=> $int; // works > $int <=> $myClass; // if this doesn't produce a warning it at least > doesn't behave the same as the line above it It does behave the same as the line above (with the result inverted, obviously) — MyClass::compareTo() is still called in this case. The only time ordering matters is if two objects are being compared, in which case the leftmost one is the one that has its compareTo() method called. > But even here I would rather just take a function instead of requiring > it to be the instance of some interface: > > function sort($input, callable $comparator($a, $b): int) { > /* … */ > } Fair, but the sorting case isn't the only one that matters, particularly with <=> now as part of the language. > I do want to thank you for taking the time to cite arguments, prior > history and an alternative in the RFC. You have done a pretty good job > on the RFC itself, in my opinion. Thanks. :) Adam -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php