Re: idea: implement a Comparable interface
To me, it sounds that those extremely specific cases ask for a extremely
specific compareTo(stdClass) method.
Daniel Ribeiro Gomes Pereira
Twitter <https://twitter.com/#!/drgomesp> |
Facebook<https://www.facebook.com/profile.php?id=100000407054469>
| LinkedIn <http://www.linkedin.com/pub/daniel-ribeiro-gomes/21/414/39>
iPhone: +55 (48) 9111-0931
2013/5/7 Stas Malyshev <[email protected]>
> 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
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Thread (17 messages)