Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120593 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52448 invoked from network); 15 Jun 2023 15:39:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Jun 2023 15:39:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2F63418053F for ; Thu, 15 Jun 2023 08:39:43 -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,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.216.0/22 X-Spam-Virus: No X-Envelope-From: Received: from beetle.pine.relay.mailchannels.net (beetle.pine.relay.mailchannels.net [23.83.219.15]) (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 ; Thu, 15 Jun 2023 08:39:41 -0700 (PDT) Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id EC284261E27 for ; Thu, 15 Jun 2023 15:39:37 +0000 (UTC) Received: from nl1-ss105.a2hosting.com (unknown [127.0.0.6]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id E234B261C6F for ; Thu, 15 Jun 2023 15:39:34 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1686843575; a=rsa-sha256; cv=none; b=QeEWpNrtQGtkp7ZXNrDXSoxPWggN6EOZE6LxTLUifUae9dhdyJynbmZmTay2ApqaJblCY3 ZVMgK0fJMfdM+AwbMRDpgTVkezxGOYn+tCWI9p7sKCzxaSOHjPaNZVilKArWesMATwLGGO ATqdp9ZsApwafkmG6nssmYv19MKKNiVaUflU3a9ZCFzFEBZLm8fA/1hYKczKVCs5E1vVIJ wfB56i1c8z3zEcp5i7vOvPXaslZdNmqifDQKkt5tclb5Nf0QwSHbhjMGOd4WwBWtu8/WgV /NCqRocejt8137/mVevdkf3XcCEWpsMUWeeBC1qwSP968ymf+6sZ+iJ387TSgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1686843575; 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=7aS73yG+84XlWlTq9Zpkhz/KwjCgExWwrH924Y0aWA8=; b=5Dz9CJ9Mcd333z82VoKOYFslCB7V4KyrdgnyiE2MhF9ggdOEcB3IoERXQNGxJ1XV2JIHY6 PGRJqUzCmQZtaBCAXTtMn7KbKg2Yls6e3fO/KFq6XwEWvoTeBaHKiTXwBHn3RH+YjkYqF5 ktuCI6HK+FD+qK9n67aGvJ+nvAPAlRrO0vtZvdJzB3N8jgyZNWK4Nxtfp+NLtDTLv3g5ve +p5IEJuJqC+wf+nsQkWHbeG8XrZDpVAsop+4CemwSYzF90Yp6eDwu5P2480+aF1kr9xjM1 oTb0aj5H7dt8b7b1CNGPXZxIoH7FreS87N1ub1kxkA8naY08QIutCtnPGoyWFg== ARC-Authentication-Results: i=1; rspamd-9fcc56855-9xhvq; auth=pass smtp.auth=a2hosting smtp.mailfrom=php-internals_nospam@adviesenzo.nl 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.119.120.20 (trex/6.9.1); Thu, 15 Jun 2023 15:39:37 +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=7aS73yG+84XlWlTq9Zpkhz/KwjCgExWwrH924Y0aWA8=; b=dpULMU6rKTGCG1Vnfw1mDD54u6 mKwMCkgOGwnbgv6VnwFg9qVVE6AsL/H9MJsrId92y6F/cQUEU1D+MlZyfmWTy5pf+72bn0+JNHZ1x nJLZU8a5eK50QA4GSQBrK0sNh9nDHnaGzptcZyJd1H2svG3btFrKyRltZscQWww9adLA=; Received: from [143.178.154.86] (port=51569 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 1q9p4R-002zTV-1C for internals@lists.php.net; Thu, 15 Jun 2023 17:39:33 +0200 To: internals@lists.php.net References: <648AAE1D.9070805@adviesenzo.nl> Message-ID: <648B30B5.50705@adviesenzo.nl> Date: Thu, 15 Jun 2023 17:39:33 +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="------------020601000109040103070603" X-AuthUser: juliette@adviesenzo.nl Subject: Re: [PHP-DEV] [RFC] Interface Default Methods From: php-internals_nospam@adviesenzo.nl (Juliette Reinders Folmer) --------------020601000109040103070603 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 15-6-2023 16:52, Levi Morrison via internals wrote: > On Thu, Jun 15, 2023 at 12:22 AM Juliette Reinders Folmer > wrote: >> On 15-6-2023 5:47, Levi Morrison via internals wrote: >>> I am moving my RFC for interface default methods to discussion: >>> https://wiki.php.net/rfc/interface-default-methods. >> 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 ? > You mis-interpreted what I was trying to say, so I'll try to clarify > that first, and then secondly address your question. > > If there an existing interface, say: > > interface Interface1 { function method1(); } > > The RFC is saying that if you added a default implementation to > `method1` without changing its signature at all, then that would not > be a compatibility issue. All existing implementers have somehow > implemented this method already, so adding a default will do nothing > (it will be unused). > > As to your questions about incompatible signatures, it's not any > different from any other interface method. If you add a new method to > the interface, and it's not compatible with some existing method on an > implementer, then it's a compatibility issue. That's not changing with > default methods. What is changing is that if a new method is added to > an interface, and it has a default implementation, it's way less > likely to be a compatibility break, because we only have to worry > about methods that share the same name. Without default methods, > essentially all additions would be compatibility break. > >> 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 ? > A key difference is that you can implement many interfaces, but can > only extend a single class (abstract or not). For this reason, many > contracts are formed with interfaces and relatively fewer with > abstract classes. Well, that's my experience, anyway. > Fair enough and thank you for your response. You were right, I copy/pasted the wrong sentence to quote. I still believe this information should be added to the RFC as the risk of adding new methods to an interface which collide with existing methods in implementations of that interface is very real, though I agree with Deleu that this BC impact is not so much of the RFC, but of what can happen once the RFC would be accepted. While I can understand the tendency to defer this question to "that's an issue for userland when userland adds new methods to existing interfaces" (or PHP itself if new methods would be added to PHP native interfaces), I don't think that's fair as this RFC is the one which opens the door to that possibility. Smile, Juliette --------------020601000109040103070603--