Re: [RFC] User Defined Operator Overloads (v0.6)

From: Date: Tue, 21 Dec 2021 05:41:27 +0000
Subject: Re: [RFC] User Defined Operator Overloads (v0.6)
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-116693@lists.php.net to get a copy of this message
On Tue, Dec 21, 2021, 6:37 AM Andreas Hennings <andreas@dqxtech.net> wrote: > > In a class Matrix, you might want to implement three variations of the > * operator: > - Matrix * Matrix = Matrix. > - Matrix * float = Matrix. > - Matrix * Vector = Vector. > Same for other classes and operators: > - Money / float = Money > - Money / Money = float > - Distance * Distance = Area > - Distance * float = Distance > these are bad examples and nightmare to maintain. I think even more with lovely typed languages. Matrix*float are better implemented as method here. >

« previous php.internals (#116693) next »