hi Gustavo, On Sun, Oct 3, 2010 at 7:34 PM, Gustavo Lopes <glo...@nebm.ist.utl.pt> wrote:
> You raise a fair point -- the motivation to override the comparison operator > for internal classes is indeed bigger because the state is not in the usual > places. However: > > * The functionality already exists; comparison operators already have their > meaning "changed" (read: user-defined) for some objects. > * I'd argue the current behavior (comparing classes and properties) is of > limited use for equality. It's common to lazy-load the properties of the > objects, which makes the current comparison behavior unreliable. > * The current behavior for >, <, etc. is completely useless. It's > unpredictable and it doesn't even establish a total order: > > $a = new stdclass; > $a->prop = null; > $b = new stdclass; > $b->prop2 = null; > > var_dump($a > $b); //false > var_dump($a == $b); //false > var_dump($b > $a); //false It may be why Stas' proposal could fit better, a comparable interface. As there is then no confusion with undefined and useless behaviors with normal comparison ops. Cheers, -- Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php