Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120604 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 61716 invoked from network); 16 Jun 2023 17:18:32 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Jun 2023 17:18:32 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D3D721804BE for ; Fri, 16 Jun 2023 10:18:30 -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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS29838 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 16 Jun 2023 10:18:30 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 3F011320083A for ; Fri, 16 Jun 2023 13:18:29 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Fri, 16 Jun 2023 13:18:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1686935908; x= 1687022308; bh=JJ+GO2GA3DNiP/Xd3E2Xd7c+dt5VTajpEQbjN8ehbeI=; b=d BOMf+evi6m2C0UwfsFPo2Hn0tB5hRze8Bf9Le6FFwsHhAsghhUfqeACN1tkkfAm5 UD584NeLsj7vIzGNmRo+gawVnhhI5LcU5+YMej6E6Dn3/pmznyOsPBop3KXtDTH/ Zqhmm0T1S4G+s4d4Hofw7pz6ErTMAw1/EJCHvhg8PbarnLT2+oyMS8B/7uyixNOb YuDl8Lz2Q9siSPrtmLTSw6rwCoNFvPgYfrwQk1V7RNxiLFkKesqL51MEwXAZhDpg Ikj4jKPsRW5XT0DCw6o0CQcoypUlFMG1em1pQ2wxw8jd+HWlDGzDjGnTmPm2259W WGaDDGeQHkaS+/K2435jA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1686935908; x=1687022308; bh=JJ+GO2GA3DNiP /Xd3E2Xd7c+dt5VTajpEQbjN8ehbeI=; b=aY/RY2TZPee9SZGBYlEdamxPVv+0F Ud0ZF2oi4nu1YKNektepqcan8pd4NeqCirBt4rZDCc05yWAzrPzcJoB3AVJMR1kM iGpDT9wvIdCiKPWBAyYHBNlhM8nJtRGqz6r1QneLleQaJF9LO2AFnBza+sAcT3RU il6nS/P/w00THuk+ZE8dQM2nt+6s4JbwfQk0tFLACYhWImXXgQcd8KbFStS1h888 ByZJCuoEP6OUfvPKvlj/lKDzj1GSOd0qV3kp5h7qsRzvD9d7+S8OAXNSMsuwfKAM STDlEuLqNbmMDqnXGM0F2Xb/gswYTjBJeYdLcZkOG7VvEpaGYEvM9oWUw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgedvgedgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepveehhedvveejledvvefgleevffdtjeekledvkeeg heffgfeivdejhffhledtudetnecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhf ihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 8CF361700089; Fri, 16 Jun 2023 13:18:28 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-496-g8c46984af0-fm-20230615.001-g8c46984a Mime-Version: 1.0 Message-ID: <6805a0b7-1bd8-41ce-9003-b45d86e191db@app.fastmail.com> In-Reply-To: References: Date: Fri, 16 Jun 2023 17:18:07 +0000 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Interface Default Methods From: larry@garfieldtech.com ("Larry Garfield") On Thu, Jun 15, 2023, at 3:47 AM, Levi Morrison via internals wrote: > Hello, PHP Internals, > > I am moving my RFC for interface default methods to discussion: > https://wiki.php.net/rfc/interface-default-methods. > > This can be a useful tool for a few reasons: > 1. It can make implementing an interface easier when certain methods > can be implemented by other methods in the interface. For example, if > `Countable` had an `isEmpty(): bool` method, it could be implemented > by doing `$this->count() > 0`. Of course, if an implementation can be > more efficient, they are still free to implement it how they want. > 2. It can mitigate BC breaks in some cases. It's somewhat common for > authors to want to expand new methods onto existing interfaces over > time. Although this would still be a BC break, it moves it from a > massive change (every single implementor must add something, even if > it's a stub, or it will fail to compile) to a naming collision issue > only (only classes which already had a method of the same name will > fail to compile). > > There is prior art for this feature in both Java and C#. There may be > other languages, but I was aware of at least these. > > Note that the RFC links to a partial implementation. If there are two > or more interfaces with default methods of the same shape (name, args, > etc) and a class implements both interfaces and doesn't provide a > concrete implementation, which default implementation should be > chosen? There is a proposal for resolving this in some cases which is > modelled after Java's implementation, but it isn't implemented. > > Thank you for your time. I look forward to productive feedback. This would essentially replace the semi-common pattern of providing an interface, and a trait that implements most of the interface for you. I have many conflicting thoughts on this RFC. On the plus side, the flexibility it provides sounds delightful, and it would effectively render abstract classes almost entirely pointless. On the down side, multiple inheritance is often avoided for a reason, and as Ilija noted it doesn't *completely* replace traits and base classes as it doesn't apply to non-public methods. From a BC perspective it seems fine. It's at worst the same as now, and potentially makes extending existing interfaces easier. I think I am overall positive, but still a bit uneasy and having a hard time articulating why. --Larry Garfield