Re: idea: implement a Comparable interface

From: Date: Tue, 07 May 2013 20:37:37 +0000
Subject: Re: idea: implement a Comparable interface
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-67362@lists.php.net to get a copy of this message
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 <smalyshev@sugarcrm.com> > 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 > >

« previous php.internals (#67362) next »