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

From: Date: Fri, 17 Dec 2021 18:36:25 +0000
Subject: Re: [RFC] User Defined Operator Overloads (v0.6)
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-116675@lists.php.net to get a copy of this message
Hi!

On 12/17/21 9:43 AM, Matt Fonda wrote:
Hi Jordan, Thanks for the RFC. I have a couple questions: Suppose I have classes Foo and Bar, and I want to support the following operations: - Foo * Bar (returns Foo) - Bar * Foo (returns Foo) If I understand correctly, there are three possible ways I could implement this:
And that's one of the reasons I feel so uneasy with this. When reading this code: $foo * $bar - how do I know which of the ways you took and where should I look for the code that is responsible for it? When I see $foo->times($bar) it's clear who's in charge and where I find the code. Terse code is nice but not at the expense of making it write-only. -- Stas Malyshev smalyshev@gmail.com

Thread (45 messages)

« previous php.internals (#116675) next »