RE: [PHP-DEV] idea: implement a Comparable interface

2013-05-07 Thread Christian Stoller
> On Tue, May 7, 2013 at 6:17 PM, Thomas Anderson wrote: > > > It'd be nice if, when doing $objA > $objB, that that'd invoke > > $objA->__compareTo($objB) or something, much like Java's Comparable > > interface. > > > > Do you have examples of what this would be useful for? The two things that > c

Re: [PHP-DEV] idea: implement a Comparable interface

2013-05-07 Thread Daniel Ribeiro
To me, it sounds that those extremely specific cases ask for a extremely specific compareTo(stdClass) method. Daniel Ribeiro Gomes Pereira Twitter | Facebook | LinkedIn

Re: [PHP-DEV] idea: implement a Comparable interface

2013-05-07 Thread Stas Malyshev
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 Co

Re: [PHP-DEV] idea: implement a Comparable interface

2013-05-07 Thread Stas Malyshev
Hi! > Classes without the ability to overload the comparison operator could be > considered kinda useless as well. That's demonstrably false - classes are very useful right now in PHP yet no overloading of operators exists. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm

Re: [PHP-DEV] idea: implement a Comparable interface

2013-05-07 Thread Thomas Anderson
On Tue, May 7, 2013 at 1:05 PM, Nikita Popov wrote: > On Tue, May 7, 2013 at 6:17 PM, Thomas Anderson wrote: > >> It'd be nice if, when doing $objA > $objB, that that'd invoke >> $objA->__compareTo($objB) or something, much like Java's Comparable >> interface. >> > > Do you have examples of what

Re: [PHP-DEV] idea: implement a Comparable interface

2013-05-07 Thread Jake Bell
I proposed something similar recently in the PHP-FIG group, but decided that without the language-level ability to overload comparison operators, standardizing comparables ony using methods was not very useful. If PHP could provide a magic method for comparison that involved being able to use c

Re: [PHP-DEV] idea: implement a Comparable interface

2013-05-07 Thread Stuart Langley
Classes without the ability to overload the comparison operator could be considered kinda useless as well. On Tue, May 7, 2013 at 11:11 AM, Daniel Ribeiro wrote: > Its kinda useless feature for PHP. > > > Daniel Ribeiro Gomes Pereira > Twitter | > Facebook

Re: [PHP-DEV] idea: implement a Comparable interface

2013-05-07 Thread Daniel Ribeiro
Its kinda useless feature for PHP. Daniel Ribeiro Gomes Pereira Twitter | Facebook | LinkedIn iPhone: +55 (48) 9111-0931 2013/5/7 Nikita Popov

Re: [PHP-DEV] idea: implement a Comparable interface

2013-05-07 Thread Nikita Popov
On Tue, May 7, 2013 at 6:17 PM, Thomas Anderson wrote: > It'd be nice if, when doing $objA > $objB, that that'd invoke > $objA->__compareTo($objB) or something, much like Java's Comparable > interface. > Do you have examples of what this would be useful for? The two things that come to mind are

Re: [PHP-DEV] idea: implement a Comparable interface

2013-05-07 Thread Adam Harvey
On 7 May 2013 09:17, Thomas Anderson wrote: > It'd be nice if, when doing $objA > $objB, that that'd invoke > $objA->__compareTo($objB) or something, much like Java's Comparable > interface. I wrote https://wiki.php.net/rfc/comparable a couple of years ago — there's a patch there that would proba

Re: [PHP-DEV] idea: implement a Comparable interface

2013-05-07 Thread Levi Morrison
> It'd be nice if, when doing $objA > $objB, that that'd invoke >> $objA->__compareTo($objB) or something, much like Java's Comparable >> interface. >> > > There is nothing stopping you from creating this in user-land. Also, I > have spent a lot of time writing libraries in PHP and I now believe th

Re: [PHP-DEV] idea: implement a Comparable interface

2013-05-07 Thread Levi Morrison
> It'd be nice if, when doing $objA > $objB, that that'd invoke > $objA->__compareTo($objB) or something, much like Java's Comparable > interface. > There is nothing stopping you from creating this in user-land. Also, I have spent a lot of time writing libraries in PHP and I now believe that this