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

2013-05-08 Thread Christian Stoller
On Tue, May 7, 2013 at 6:17 PM, Thomas Anderson zeln...@gmail.com 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

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

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

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

2013-05-07 Thread Adam Harvey
On 7 May 2013 09:17, Thomas Anderson zeln...@gmail.com 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

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 zeln...@gmail.com 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

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 https://twitter.com/#!/drgomesp | Facebookhttps://www.facebook.com/profile.php?id=10407054469 | LinkedIn http://www.linkedin.com/pub/daniel-ribeiro-gomes/21/414/39 iPhone: +55 (48) 9111-0931 2013/5/7 Nikita Popov

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 drgom...@gmail.com wrote: Its kinda useless feature for PHP. Daniel Ribeiro Gomes Pereira Twitter https://twitter.com/#!/drgomesp |

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

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 nikita@gmail.com wrote: On Tue, May 7, 2013 at 6:17 PM, Thomas Anderson zeln...@gmail.com 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

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:

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

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 https://twitter.com/#!/drgomesp | Facebookhttps://www.facebook.com/profile.php?id=10407054469 | LinkedIn