Re: [VOTE] Interface Default Methods

From: Date: Tue, 11 Jul 2023 15:51:45 +0000
Subject: Re: [VOTE] Interface Default Methods
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-120778@lists.php.net to get a copy of this message
Le 11/07/2023 à 17:16, Robert Landers a écrit :
On Tue, Jul 11, 2023 at 4:36 PM Larry Garfield <larry@garfieldtech.com> wrote:
You have to check your vendor folder for an interface, or trait, or abstract class. That doesn't change anything. As noted, now consider a Baz interface. For interface-and-trait, you add 2 more definitions. For interface-with-defaults, you add 1. For abstract classes, you need to add 4: BazBase, FooBazBase, BarBazBase, and FooBarBazBase.
I guess I don't understand what the interface is solving if you're creating an interface _and_ a trait, why not just create the trait? It
What's solved here is that you simply don't have to create the trait anymore, in this specific use case, no more, no less. And I do like it. You may not see the point for it, but as a recurrent user of the interface+trait from another package, it does bothers me a lot because it's never clear about the intent when you don't know the trait exists. Having the interface default methods makes it self-documenting and much clearer for the user. There's nothing complex here, it's pure sugar candy, and much appreciated one by many I guess.
sounds like you're coupling your interface to a specific implementation and trying to get multi-inheritance out of PHP. This seems like a design issue, and this RFC seems like a back-way to multiple inheritance. Why not just allow multiple inheritance?
Regarding the "back-way to multiple inheritance", it's true, and that's how lots of languages that were not design with multiple inheritance in mind solves it, such as Java, and I personally find this rather elegant. -- Pierre

« previous php.internals (#120778) next »