Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120636 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 42660 invoked from network); 20 Jun 2023 07:59:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Jun 2023 07:59:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B3EB3180089 for ; Tue, 20 Jun 2023 00:59:27 -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=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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, 20 Jun 2023 00:59:27 -0700 (PDT) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-3f90b4ac529so28618795e9.0 for ; Tue, 20 Jun 2023 00:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687247966; x=1689839966; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=e//maorC2DUDknLm4kSxQXB2gYw2kyeT9qFV5V3rgDc=; b=BOTjv99LJYS+MWY4DctguMDYcT4GuJRCyN8uZSEHapBIR9k34YwyqpZw/6Zc6+5HHx ajFr5XDhlaEdEHUi/lSJmEwfmDs0W/oO5O69f1yraCg/mS3t+g4KwZQ9wEZO/V6dsaQK 9k+kUXw0aLW5JoqGLdkD/rcabkx0VNb/ilaJ36kvB3Zn6ux0AMr6R8SLEFojKhUY1sbT Z/bd7QP+cxKhn5XuyRrvh6Zi3cpfpH2KR0aM1m+xd4TaJEhuM3LE06/B68e6OskDoLvZ pKRSKjYOLW7iM9Kqh5kGF3vGrXMrjj2ZZXebrMgiT882kOZ6uf+u077+wdnukHfQSKre M/PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687247966; x=1689839966; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=e//maorC2DUDknLm4kSxQXB2gYw2kyeT9qFV5V3rgDc=; b=RKwZHxtAyCxnUbShmgiqgAKr/MIC+OKivfcIbojCThbMPe8Fe+BkG23pAWCuXCqMHr dP4rw08cmanB7K0x3+K4uUmhlScAAGX975IX0xcS0PYFAJ1YcSp/Z87JB+egArsivzTq dz4+zlqfBz7vs3j/WME9zjiPkLamlrYDCDU4yNLS4WQBfjUawlv81kOcNbVi/fuKqUOq xsVZal9i9vOJ1YxBr9ck3UPN5+NXd5MfPwB8WTgAy5Q14LUgcxqvEBLPDelfEeEb/8Li uXbOQ4gNssL7sMjKd026cz3+5UhxvEGpbKkmxsn7wd6f5aEOqKX6+TuRgAdLOAhENrPZ 3rTg== X-Gm-Message-State: AC+VfDwaM3kwA5ryAjGGTxHpmhn8kvFmeY+5lwB6aWy3bxqP5E67YgFE hIVgcUKznOhhok0L8/Rt5pXXYVfYyg0= X-Google-Smtp-Source: ACHHUZ772ddWB4wTtM8UJDxcXc94d96Hu0/FcsO7p2rtIRRbxnQyiUsL9+COIfkDYPU1AbRh3s/qnw== X-Received: by 2002:a1c:ed08:0:b0:3f6:58ad:ed85 with SMTP id l8-20020a1ced08000000b003f658aded85mr9156598wmh.10.1687247965590; Tue, 20 Jun 2023 00:59:25 -0700 (PDT) Received: from [192.168.0.22] (cpc83311-brig21-2-0-cust191.3-3.cable.virginm.net. [86.20.40.192]) by smtp.googlemail.com with ESMTPSA id f20-20020a7bcd14000000b003f7f2a1484csm1689288wmj.5.2023.06.20.00.59.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Jun 2023 00:59:25 -0700 (PDT) Message-ID: <6e114796-b4a0-6ea6-e681-f6cfa1bf750b@gmail.com> Date: Tue, 20 Jun 2023 08:59:24 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 To: internals@lists.php.net References: Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Interface Default Methods From: rowan.collins@gmail.com (Rowan Tommins) On 19/06/2023 22:12, David Gebler wrote: > > Sure, but in this example were B::bar() to be a private method, > you would get a scope violation error. You would not if you were to > use a trait, since any methods implemented in the trait would be > executed in the same scope as the class using the trait. And that > seems to be what's being proposed here for interface defaults. So my > concern here is that when you use a trait, you know that what > you're doing is effectively copy-and-pasting implementation into your > class scope. You don't expect that when you declare a class to > implement an interface. That's a crucially different example - it's not about whether the interface has to declare everything it uses, but about what scope it operates in. The RFC should probably spell it out more clearly, but my interpretation was that the methods are being inherited just like if they were on an abstract class, not "pasted" like a trait - e.g. the example of delegating to an interface method would not work with a trait. As such, they would execute in the scope of the interface, and have access to protected but not private members of the class that inherits them. This is also hinted at in the exchange between Levi and Alexandru about private methods on the interface itself, which would not be visible anywhere outside the interface. Again, that's different from traits, where members marked "private" are private to the target class, not the trait. Regards, -- Rowan Tommins [IMSoP]