Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118418 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 79219 invoked from network); 11 Aug 2022 16:53:24 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Aug 2022 16:53:24 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6068B1804AF for ; Thu, 11 Aug 2022 11:55: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 wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 11 Aug 2022 11:55:29 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id A41FF32009FB for ; Thu, 11 Aug 2022 14:55:28 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Thu, 11 Aug 2022 14:55:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc: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=fm1; t=1660244128; x= 1660330528; bh=/xerWVoNLZkBpHRYQ3Oj874UbnPMitOKsMzjuWSa8Ss=; b=e hYcVMWqX4x78VWkzywgpfKVDgpBaWw6tQz+r7pctvbeObzYwzwsn+wagNcpm1EpK j9ODI4UiVkELOL+sKET24WSdGFcHAr0XYmpogbTZVqTw1CcqLOloqMmoU7AK+0Et C1Pk5rv9BmmEeUqC2VLO+npPvk5zGj5CfJgoFL8WMLPrv+UF36HC0vUtgkfFSSVG KRYultKsIYA8U6nc7e5gyPPBOeITxeqF6T7v4dA+83uPucOBlPXNDmQ5o4tbFGYR pxYMA0MdCq0qGFRdgqQ1qcWSYCnKFKAcTR/I2LjBf94K1a87C2Fv5G+8aCzk62+4 cJj8fNp+6OWQO0weO3swg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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= fm1; t=1660244128; x=1660330528; bh=/xerWVoNLZkBpHRYQ3Oj874UbnPM itOKsMzjuWSa8Ss=; b=aq6NTrE2dIhAocys7p8YLH34V7Y7rrhcqJ5CSsqPXvBt wkEDfSmDWnEEqTU+WsXxXtCX37o0AItgz1IZP4K2XUR+jCmNAXX4KauXdVbzhiiL 3IABuNG5s4oebvDOcRb5Kyhu0qY0bxCEF1ODZTaynd5jidyr1GUoc2Es/l+N4fhb NQVuPy/1vNZ5uhFdm2dWlnsikA3/l/bLNCPVJKvJSt4Fa48snJaNXSDm7OGdpMVN 2MdvokszBWU9qH8keEVMQIbwZQdb+wa3G/UivxvpEPEYzBzUg5gYZ+fHrniODbJt W8ydGDD9rQJwl1bOnbyYFg2h9s8AhSXq1GUevGWrgg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdeggedgudefudcutefuodetggdotefrod 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 F08421700082; Thu, 11 Aug 2022 14:55:27 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-811-gb808317eab-fm-20220801.001-gb808317e Mime-Version: 1.0 Message-ID: <483e87df-61f9-4cb4-b3ce-03b8f8d81d25@www.fastmail.com> In-Reply-To: References: Date: Thu, 11 Aug 2022 13:54:34 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Asymmetric visibility From: larry@garfieldtech.com ("Larry Garfield") On Thu, Aug 11, 2022, at 8:48 AM, Nicolas Grekas wrote: >> Ilija Tovilo and I are happy to present the first new RFC for PHP 8.3: >> Asymmetric Visibility. >> >> https://wiki.php.net/rfc/asymmetric-visibility >> >> Details are in the RFC, but it's largely a copy of Swift's support for the >> same. >> > > Thank you Larry and Ilija for this RFC. > > After reading it, I'm wondering about inheritance rules. What would be the > rules when redeclaring an existing asymmetric property in a child class? > The RFC should mention them I believe. Yeah, Ilija is working on that still, I believe. I believe the plan is, as with properties now, to allow widening access but not narrowing. static properties will also be supported, but that implementation is WIP. > But I'm also wondering about the use case where asymmetry would be useful > in practice now that we have readonly? > I voted against readonly at the time because it didn't address cloning, and > also because it deprives end-users vs code authors IMHO (alike "final"). I > would have very much prefered asymmetric visibility back then. But now that > we are here, what are the use cases? If it's cloning only, then I would > very much prefer finding a way to fix it rather than providing two subtly > different ways to achieve the same thing. > > Eg can't we allow __clone methods to bypass the readonly restrictions? The > engine already handles "guards" when using magic property accessors. Can't > we use something similar for clone? > > And if yes, what would remain of the motivations for the asymmetric RFC? > > Cheers, > Nicolas There's a couple of use cases I see off hand: 1) Cloneability, as you've noted. 2) Fixing inheritance with readonly. Right now, readonly is only settable from private scope, not protected. So child classes are SOL. 3) A property that is rebuild based on other properties. Eg, public private(set) $fullName, which is updated internally whenever $o->setFirstName() or $o->setLastName() are called. (Or with accessor hooks in the future, which is on the roadmap.) There's likely others, too. I would also have rather had AV in the first place rather than readonly, as readonly is now getting in the way. :-( But there are things readonly cannot reasonably do, and that's made worse by bad assumptions that static analysis tools have made about its usage. We're working on a response to some other points made, but want to get on the same page with some more details first. Stay tuned for a follow up. --Larry Garfield