Re: [PHP-DEV] Operator overloading for userspace objects

2020-01-31 Thread Larry Garfield
On Fri, Jan 31, 2020, at 11:32 AM, Mike Schinkel wrote: > > On Jan 31, 2020, at 10:41 AM, Larry Garfield wrote: > > > > I cannot speak to the implementation details. From a design perspective, I > > am tentatively positive on operator overloading, with separate method for > > each operator, BU

Re: [PHP-DEV] Operator overloading for userspace objects

2020-01-31 Thread jan.h.boehmer
> I cannot speak to the implementation details. From a design perspective, I am tentatively positive on operator overloading, with separate method for each operator, BUT, the big question for me is the rules around type compatibility. > > Can you only compare 2 of the same type? What about subcla

Re: [PHP-DEV] Operator overloading for userspace objects

2020-01-31 Thread Ben Ramsey
> If we still want operator overloading and we want to force operator > overloading to require immutability, I believe that means we would need an > immutability RFC to be approved (and implemented?) before operator > overloading requiring immutability could be approved. Something like this:

Re: [PHP-DEV] Operator overloading for userspace objects

2020-01-31 Thread Mike Schinkel
> On Jan 31, 2020, at 10:41 AM, Larry Garfield wrote: > > I cannot speak to the implementation details. From a design perspective, I > am tentatively positive on operator overloading, with separate method for > each operator, BUT, the big question for me is the rules around type > compatibili

Re: [PHP-DEV] Operator overloading for userspace objects

2020-01-31 Thread Benjamin Morel
I like this whole operator overloading thing. I would probably use it in brick/math and brick/money to replace verbose `->plus()`, `->multipliedBy()` etc. calls. > Can you only compare 2 of the same type? What about subclasses? Can

Re: [PHP-DEV] Operator overloading for userspace objects

2020-01-31 Thread Ben Ramsey
> Also, I want to reiterate: Any of these operations MUST be designed to return > a new value, never modify in place. These operators only make sense on value > objects, not service objects, and value objects should be immutable. I completely agree. This was the gist of my earlier comments. Ma

Re: [PHP-DEV] Operator overloading for userspace objects

2020-01-31 Thread Larry Garfield
On Thu, Jan 30, 2020, at 3:22 PM, jan.h.boeh...@gmx.de wrote: > > Unfortunately, this implementation goes in the wrong direction: PHP already > > has full internal support for operator overloading through the do_operation > > object handler. Operator overloading should be exposed to userland thr