Re: [Pre-RFC Discussion] User Defined Operator Overloads (again)

From: Date: Mon, 16 Sep 2024 12:22:55 +0000
Subject: Re: [Pre-RFC Discussion] User Defined Operator Overloads (again)
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-125563@lists.php.net to get a copy of this message
On Sun, Sep 15, 2024 at 12:52 AM Jordan LeDoux <jordan.ledoux@gmail..com> wrote: > > These changes could and should be provided independent of operator > overloads. Gina has been working on a separate RFC which would cover all > three of these issues. You can view the work-in-progress on that RFC here: > > https://github.com/Girgias/php-rfcs/blob/master/comparison-equality-semantics.md > > Unrelated topic, sorry for the spam. I just wanted to point out that interface default methods will play nicely with the mentioned interfaces: Equatable and Comparable: interface Equatable { public function equals(mixed $other): bool; } interface Comparable extends Equatable { public function compare(mixed $other): int; public function equals(mixed $other): bool { return $this->compare($other) === 0; } } So that it signals a clear intent of: "what is comparable is also equatable, and this is the default implementation for it. Alex

« previous php.internals (#125563) next »