Re: Custom object equality

From: Date: Mon, 23 Oct 2023 17:19:52 +0000
Subject: Re: Custom object equality
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-121453@lists.php.net to get a copy of this message
On 23-10-2023 18:34, Larry Garfield wrote:
Jordan's RFC explained in detail why interfaces are not viable, which is why we have to use magic methods (with or without a special keyword) instead: https://wiki.php.net/rfc/user_defined_operator_overloads#why_not_interfaces (Seriously, it has an extensive FAQ. It's one of the more detailed and supported RFCs we've seen.)
Yes, I know the RFC, it's a great piece of work! The use of interfaces as mentioned in this RFC is however completely different from what Pierre and I are talking about. If I understand Pierre correctly, that is. The suggestion to include interfaces simply meant to allow freedom of choice. Choice between using an operator (==) or calling the equivalent method on the object (->equals()). That may get more people on board with operator overloading. Regards, Dik

« previous php.internals (#121453) next »