Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119051 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 61435 invoked from network); 29 Nov 2022 20:29:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Nov 2022 20:29:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2D34A1804BE for ; Tue, 29 Nov 2022 12:29:48 -0800 (PST) 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 wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (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 ; Tue, 29 Nov 2022 12:29:47 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id ECF983200708 for ; Tue, 29 Nov 2022 15:29:43 -0500 (EST) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Tue, 29 Nov 2022 15:29:44 -0500 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=1669753783; x= 1669840183; bh=sdNPnPTBcl9A1AJniiIDvbEAYwiY5sECDEdJDTfTlBE=; b=U zdL6CNudRw4fwDxOQ63jysdy0pemVYmXvE52jcKbAwKprC5k3EzFq3+896E0chG6 ROcjpB4SotADzC0iFHfiheGjk7z78viGUQMu1tnMEgMZk5fF8mhX5vcJHTM5JFnU 3QefxfwGt1D2+8i6IPzEMU6N4lZRNNKk2DOMM8JGPRcuMRLN3Wl+JbjrlrsJK/sD UiXpn+iLmcIVkL0J0/tvRunH++sje9e3DeylXBDxXziSvChGs+bT5w9GqJTGvFXt grFrr6hUNmVo+P+FxyASj1dJ8VL0kp5SUSbMI3D5nJ709iDO9gMkeV895sRnnvBo VY190ut52c1Ip980wk55A== 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=1669753783; x=1669840183; bh=sdNPnPTBcl9A1AJniiIDvbEAYwiY 5sECDEdJDTfTlBE=; b=NNgRbuJb5WxiUMBBkBN/33Tnf2LXb9oyibb2kco4G7SE x1dkyc1NSe347oG8NIfqNftGpBjKTd+4psXzbHhFs2FwsrOiZk6QFGWV4e0ClqEF C2zasZh/5d5PUHn6FNZZ8EEAabil4zyl0uddzgromUhi8N/DjBr0rUg56EA68eqU +XRO0gId8TiKV7rlVMbynsuuM8+KRaSpgdU1H+Go6boX3wWp3c1B2nOIVJd8KS+k sRO2vObJT1TaEgDNbq8LP5z/rRN54sWfP9cczWHJOeGmZA5Y1wj6xA0Q410WfbQU JKqVILQkFS9b3SEk8IM1+BZ+yclWlCH45h11aPkM/Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrtddtgddutdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 324051700089; Tue, 29 Nov 2022 15:29:43 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1115-g8b801eadce-fm-20221102.001-g8b801ead Mime-Version: 1.0 Message-ID: <831b9906-dc0c-420c-b22f-8a0cc8a1ad64@app.fastmail.com> In-Reply-To: <0854b030-c51c-4c1b-a7dd-22835a1e5da9@app.fastmail.com> References: <0854b030-c51c-4c1b-a7dd-22835a1e5da9@app.fastmail.com> Date: Tue, 29 Nov 2022 14:29:14 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Asymmetric Visibility, with readonly From: larry@garfieldtech.com ("Larry Garfield") On Sun, Nov 13, 2022, at 2:08 PM, Larry Garfield wrote: > Hi folks. Ilija is nearly done with the implementation for asymmetric > visibility and flushing out edge cases, but we've run into one design > question we'd like feedback on. > > There's two design decisions we've made at this point, both of which we > think are logical and reasonable: > > 1. If specified, the set visibility must be tighter than the get > visibility. So `protected protected(set)` and `protected public(set)` > are not permitted, for instance. > > 2. `readonly` is a "write once" flag that may be combined with > asymmetric visibility. If no set visibility is specified, `readoly` > implies `private(set)`, but a different set visibility may also be > provided. > > These are both reasonable rules. However, it creates a conflict. > Specifically, in the following cases: > > public public(set) readonly string $foo > > protected protected(set) readonly string $foo > > These would be the only way to have a non-private-set readonly > property. While the first is in practice quite unlikely, the second > has valid use cases. (In particular, a base class that provides > properties expected to be set by a child constructor, and then used by > a method in the parent class.) However, it would not be allowed under > the rules above. Working around it would require specifying `public > protected(set) readonly...`, which means exposing a property that > likely should not be exposed. > > That creates an odd situation where readonly and asymmetric visibility > may only be combined "sometimes." That is not deesireable. The only > way to combine them in their current form is to allow `protected > protected(set)` only if readonly is in use, which is excessively > complicated both to implement and to explain/document/use. > > We see two possible ways to resolve this conflict: > > 1. Relax the set-is-tighter restriction. That would allow `protected > protected(set)` etc. on any property. It wouldn't be particularly > useful unless readonly is being used, but it would be syntactically > legal and behave as you'd expect. We could still disallow "set is more > permissive" combinations (eg, `private public(set)`), as those have no > apparent use case. > > 2. Disallow readonly and asymmetric visibility being combined, because > readonly already has a hard-coded implied asymmetric visibility. This > option removes some potential use cases (they would most likely drop > the readonly), but has the upside that it's easier to re-allow at some > point in the future. > > 3. Some other brilliant idea we've not thought of. > > > Both are viable approaches with pros and cons. We're split on which > way to go with this, so we throw it out to the group for feedback. > Which approach would you favor, or do you have some other brilliant > idea to square this circle? Thank you everyone for the feedback. Based on this thread, we've made two changes to the RFC: 1. We've moved readonly back to forbidden with a-viz for now. I've added a section to Future Scope where we really should sort this out in the future, but we'll do that in the future when we can all focus on the various nuances of just that piece. 2. I rewrote the section on __set to make it clearer. That also included Ilija and I digging into all the nuances that are already present. The text may still look a bit complex, but that's because the existing logic is already complex with readonly. Long story short, the a-viz RFC does not change anything in the way __set works vis a vis asymmetric visibility; it just inherits and continues what readonly already started, so it's consistent. The PR should be updated in the next week or two with the latest changes. Baring any major need for change, we expect to call a vote for it shortly after New Years. Thanks all. --Larry Garfield