[PHP-DEV] Re: [RFC] [VOTE] User-defined object comparison

2018-07-10 Thread Rudolf Theunissen
how we should look at this. The reason why <=> normalises to -1,0,1 isn't because the operator dictates that - it's `compare_function` that does that, which is what the operator points to by default. I hope that helps to clear things up a bit. :) On Mon, 9 Jul 2018 at 13:57, Rud

Re: [PHP-DEV] Re: [RFC] [VOTE] User-defined object comparison

2018-07-10 Thread Rudolf Theunissen
> declare the variance of the `Eq` and `Ord` operations for a specific class. > > > Marco Pivetta > > http://twitter.com/Ocramius > > http://ocramius.github.com/ > > On Mon, Jul 9, 2018 at 8:57 PM, Rudolf Theunissen < > rudolf.theunis...@gmail.com> wrote: > >> Apo

[PHP-DEV] Re: [RFC] [VOTE] User-defined object comparison

2018-07-09 Thread Rudolf Theunissen
Apologies for that middle discussion link, it was a bad hyperlink from a bad paste if you look at source. Here are the correct ones: *Discussion:* - https://externals.io/message/102337 - https://externals.io/message/102473 On Mon, 9 Jul 2018 at 13:57, Rudolf Theunissen wrote: >

[PHP-DEV] [RFC] [VOTE] User-defined object comparison

2018-07-09 Thread Rudolf Theunissen
Hi everyone, With no further discussion and no objection to start voting on this RFC, I would like to move forward with the vote, which requires a 2/3 majority to pass. *RFC*: https://wiki.php.net/rfc/object-comparison Discussions: - https://externals.io/message/102337

Re: [PHP-DEV] [RFC] User-defined object comparison

2018-07-05 Thread Rudolf Theunissen
Fixed! Thanks Christoph, I guess I've been typing "PHP" too much lately. :p On Thu, 5 Jul 2018 at 11:30, Christoph M. Becker wrote: > On 05.07.2018 at 16:27, Rudolf Theunissen wrote: > > > Somewhat related, and in response to Levi's mention of it in this thr

Re: [PHP-DEV] [RFC] User-defined object comparison

2018-07-05 Thread Rudolf Theunissen
> > We can just define that == calls __equals on the left. That's, for > example, what Python does. This would produce a weird consequence of $a > == $b and $b == $a not being the same, but that's what you get for > overloading operators. That's why overloading operators is not always > the best id

Re: [PHP-DEV] [RFC] User-defined object comparison

2018-07-01 Thread Rudolf Theunissen
> > I think what I was suggesting is that if people in future want to overload > the operators specifically, we would want to provide an overload for <=> > that was separate from __compareTo, so that you could overload that without > breaking things like sorting. I think it would be confusing to

Re: [PHP-DEV] [RFC] User-defined object comparison

2018-06-30 Thread Rudolf Theunissen
> I think it's fairly crucial that this proposal is NOT just about overloading operators, it's about overloading *behaviour* That is what this RFC is trying to achieve. Equivalent in behaviour, so we're providing a way for a class to define how it compares or equates to another value. We're not pr

Re: [PHP-DEV] [RFC] User-defined object comparison

2018-06-28 Thread Rudolf Theunissen
> > In this case, the order of checking to see what method to call will also > check > for type compatibility. That is, $f < $b checks Foo::__compareTo(), finds > it > doesn't match, and so calls Bar::__compareTo() instead, which does. I'm not sure if I like this, it's a bit non-deterministic isn

Re: [PHP-DEV] [RFC] User-defined object comparison

2018-06-27 Thread Rudolf Theunissen
es Thank you On Wed, 27 Jun 2018 at 18:53, Rudolf Theunissen wrote: > In summary, I propose that return type constraints should be removed >> which will allow us to pursue specific operator overloading at a later >> point if we desire > > > There are no return types or pa

Re: [PHP-DEV] [RFC] User-defined object comparison

2018-06-27 Thread Rudolf Theunissen
On Wed, 27 Jun 2018 at 15:21, Levi Morrison wrote: > On Wed, Jun 27, 2018 at 12:24 PM Levi Morrison wrote: > > > > On Tue, Jun 26, 2018 at 5:50 PM Rudolf Theunissen > > wrote: > > > > > > Hi everyone, > > > > > > This is an RFC that is b

Re: [PHP-DEV] [RFC] User-defined object comparison

2018-06-26 Thread Rudolf Theunissen
> I would like to see this in an extension first, i think it's perfectly doable and people can test it before merging to core Actually not sure this can be done as an extension because it changes zend_operators and introduces a new handler to make it all work. > Would be nice if compareTo and equ

[PHP-DEV] [RFC] User-defined object comparison

2018-06-26 Thread Rudolf Theunissen
Hi everyone, This is an RFC that is based on previous discussions here: https://externals.io/message/102337 RFC: https://wiki.php.net/rfc/object-comparison The implementation is tested and appears to be working as expected. :) - Rudi Theunissen