Re: Revisiting Userland Operator Overloads

From: Date: Sun, 08 Aug 2021 03:26:09 +0000
Subject: Re: Revisiting Userland Operator Overloads
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-115661@lists.php.net to get a copy of this message
On Aug 7, 2021, at 15:28, Larry Garfield <larry@garfieldtech.com> wrote: > As an example here, time units. Adding two hour:minute time tuples together to get a new time > (wrapping at the 24 hour mark) is an entirely reasonable thing to do. But multiplication and > division on time doesn't make any sense at all. Or, maybe it does but only with ints (2:30 * 3 > = 7:30?), kind of, but certainly not on the same type. This touches on another important question -- how do we plan to represent: 1) An operator which is only applicable when an operator is used on two dissimilar types (e.g. TimeTuple x float)? 2) An operator which can be applied to an object, but with a primitive or otherwise non-extensible type on the left hand side of the operator (e.g. float x TimeTuple)? 3) An operator which can be used with multiple types, but whose meaning and/or return value can change based on what types are used (e.g. Matrix x Matrix vs. float x Matrix)?

« previous php.internals (#115661) next »