Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120583 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 7471 invoked from network); 15 Jun 2023 06:22:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Jun 2023 06:22:31 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1D8501804BE for ; Wed, 14 Jun 2023 23:22: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=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL, STOX_BOUND_090909_B,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS36483 23.83.208.0/21 X-Spam-Virus: No X-Envelope-From: Received: from fossa.birch.relay.mailchannels.net (fossa.birch.relay.mailchannels.net [23.83.209.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 14 Jun 2023 23:22:29 -0700 (PDT) X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 965215C1E8B for ; Thu, 15 Jun 2023 06:22:24 +0000 (UTC) Received: from nl1-ss105.a2hosting.com (unknown [127.0.0.6]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id 82D695C133B for ; Thu, 15 Jun 2023 06:22:23 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1686810143; a=rsa-sha256; cv=none; b=xTVsIdIqAfOR+NdrKoGEPTJSgcJMzK7tQaxKx6B7/Zr5e6EcCZwU+X0MkTPX6h12/QFawp bPNP2BzHtoq0aqVOtsMjGGSyhz6aZFayWt4G80+e0bpGGz1ex27VL6NoL1Ghisp6R92baY tNboQi3AdiTHGQlBgEjMyBwydpuKvbpVpZzQgyNfOm2FiCLacUwJ1GQm0JF5noEMsvMAgn pNdVGQmsoVmJWBQuONgZpYEzSyDlkoCv4+T/Q0ZRp1/v1ajhBVEZ969x5HynEr6scj7nak yLxm/Rc11/fAHv7DILUC4pl41IT47KsR1mCJZKHXv7+lMjc++lD6vJjy9gOlEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1686810143; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SsoP/cbUqCK/zVljjLF2pVLOJn+acxLfntIjtOndAjc=; b=0TXYlBNk/rzuBle/5c3fFApVm5H+NTAPK2qVcyR6fENK5gbBXlBE0ZoKAhVOGtuC2Dv3OI 6I/dncM/iKZmRCl7s7cdA2DkpAMe5CfVLQC7Pa+3h6wUlkpdCsyU6xx0InsumtcX9zPHh9 AA1QnKgunGGvgV061tgbSRnwvoCkFQFm8734K/qsuFexl6pxb2VzONroKAX+pD2T8S3SNk K7GpDv05WgtT/mNXuyg4HCqFlLCr1EjCKRofSXonMsPOR+C50X6N25L+nuQtumcG/FOrlP CyZRnUx4PhSOjBGAOneQkR18s/sV7CijvrqkcOCiygQAC1NrwhGIvBMHtFil+Q== ARC-Authentication-Results: i=1; rspamd-7c78575475-c2wn6; auth=pass smtp.auth=a2hosting smtp.mailfrom=php-internals_nospam@adviesenzo.nl X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl X-MC-Relay: Neutral X-MailChannels-SenderId: a2hosting|x-authuser|juliette@adviesenzo.nl X-MailChannels-Auth-Id: a2hosting X-Abaft-Ruddy: 7409a12147012fd1_1686810144068_4183995537 X-MC-Loop-Signature: 1686810144068:816010082 X-MC-Ingress-Time: 1686810144068 Received: from nl1-ss105.a2hosting.com (nl1-ss105.a2hosting.com [85.187.142.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.106.146.242 (trex/6.9.1); Thu, 15 Jun 2023 06:22:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=adviesenzo.nl; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=SsoP/cbUqCK/zVljjLF2pVLOJn+acxLfntIjtOndAjc=; b=KUcGuf4ZqsQ+J5MYd2JXnQua+U lcpihNo9b3hBVzau2bSbetzVSn2pDPjLJH7QbeywsVTdHQ49yufisjVjYxZhq8KkprcJf4rqBwZid yR3hwbUr5R+775fadR9HEFY64aXgu2Qhn8avFPRIkRDqahUMXorro8dTR+pmKJADVbGQ=; Received: from [143.178.154.86] (port=50914 helo=[192.168.1.104]) by nl1-ss105.a2hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1q9gNE-00Gkp3-06 for internals@lists.php.net; Thu, 15 Jun 2023 08:22:21 +0200 To: internals@lists.php.net References: Message-ID: <648AAE1D.9070805@adviesenzo.nl> Date: Thu, 15 Jun 2023 08:22:21 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------040109070003090605050101" X-AuthUser: juliette@adviesenzo.nl Subject: Re: [PHP-DEV] [RFC] Interface Default Methods From: php-internals_nospam@adviesenzo.nl (Juliette Reinders Folmer) --------------040109070003090605050101 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 15-6-2023 5:47, 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. > > Levi Morrison > Hi Levi, Thanks for the RFC. The usecase seems clear. There are two things I'm missing on an initial read of the RFC. > Adding a default implementation to an existing interface method will not break existing code, because every existing usage has a higher priority than the default. A: How would this work if the existing method in the implementing class has a different function signature than the newly introduced method in the interface ? There are two aspects to this: 1. What if the existing method has different parameters ? 2. What if the existing method has the same parameters, but different/incompatible parameter/return types ? B: How does the ability to add default method implementations to an interface compare to providing an abstract class implementing the interface and providing the default method implementations ? Smile, Juliette --------------040109070003090605050101--