Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120778 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 87840 invoked from network); 11 Jul 2023 15:51:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Jul 2023 15:51:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CD97E1804D4 for ; Tue, 11 Jul 2023 08:51:55 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS16276 192.99.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mail.processus.org (ns563681.ip-192-99-44.net [192.99.44.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 11 Jul 2023 08:51:55 -0700 (PDT) Message-ID: <78faec46-f574-38c5-1c08-bd23e4e5b375@processus.org> Authentication-Results: mail.processus.org; auth=pass smtp.mailfrom=pierre-php@processus.org Date: Tue, 11 Jul 2023 17:51:45 +0200 MIME-Version: 1.0 Content-Language: en-US To: internals@lists.php.net References: <3a3e7781-c2b4-2880-8048-d19458ac287d@heigl.org> <308d32d6-c145-4f8c-8779-101a696b60a0@app.fastmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Bar: / Subject: Re: [PHP-DEV] [VOTE] Interface Default Methods From: pierre-php@processus.org (Pierre) Le 11/07/2023 à 17:16, Robert Landers a écrit : > On Tue, Jul 11, 2023 at 4:36 PM Larry Garfield 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