Re: idea: implement a Comparable interface
| From: | Stas Malyshev | Date: | Tue, 07 May 2013 20:33:45 +0000 |
| Subject: | Re: idea: implement a Comparable interface | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-67361@lists.php.net to get a copy of this message | ||
Hi!
> I wrote https://wiki.php.net/rfc/comparable a couple of years
> ago —
> there's a patch there that would probably still apply without too much
> work to master. About the only difference was that I didn't double
> underscore the magic method (in line with both Java and PHP interfaces
> like Countable).
Overriding < and > isn't the biggest issue, even though BC issues with
conversions may definitely be a surprise. Bug biggest one is ==, which
may have a lot of very non-trivial effects if you make == return
"equals" when other functions (such as searches, hashes, etc.) may treat
them as not equal. It is quite a complex thing which is rife with
unexpected side effects, so I think it would be better if it were explicit.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227