Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119042 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 90204 invoked from network); 27 Nov 2022 16:51:22 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Nov 2022 16:51:22 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CEAD71804A9 for ; Sun, 27 Nov 2022 08:51:20 -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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (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 ; Sun, 27 Nov 2022 08:51:20 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id C26745C0086 for ; Sun, 27 Nov 2022 11:51:19 -0500 (EST) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Sun, 27 Nov 2022 11:51:19 -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=1669567879; x= 1669654279; bh=EdkMlFoRCGTHIGcnQwFriBeqvRPX78WH+vx3XNID7kI=; b=d Uxo+CqvIIaM2TL0Wu+jWk0sMDYHWPkiBr1ZKE5UbPABRasrRITQUyMunL7LV9FgS Rz+fRTb5vhHqzE9mbF/P+OYhCRd06zTH+/2FOSyA/37JkotkGVi76e9qH7ZqQG4q Fip4KF0z+6DQYSbCjkyZxmTQhw/le9LOK783qPXTUWuyny1uKeU/Tv7jUBBldDWd cWhhgsBJtHlI7+L09Z4P5K+fAvfM86U1R3wp8SthIlG9794vS5Vs2xvldlc/h7LN URtdSaFy91jgApGKdOgYSQTSM5HbfgfAHKVW9WmAyn93dMzYsECdmOwpPQi7yF2U 2wGYddak7hf5XKpjg+APw== 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=1669567879; x=1669654279; bh=EdkMlFoRCGTHIGcnQwFriBeqvRPX 78WH+vx3XNID7kI=; b=JiEVN8/QY8PcKbwphKKl7n29mjFPQ7SSpqNkiyJzj5hV PeCGRkLikV2GVjHmcWXdMDAqztsKUPhippC2VXXf7q1XtDdqCSceAPUvI8OS0SFw p8C8iku1oMEA/xxA5kcyEVqRtezgXHmRS/A/awG1dqjcrqwf/4ExSKLSOyOnRIgH pdm2CHglGBjXFaX5kTpWYtBPVjF5IWGfAkHkU/EO3CV+BCt1r892Z2g8An4n2DkK XqdhBXSUJB01dAj5T8wJuDqyd/K3C63eah2QqprGj9FHsQaLW9y3iVCvc/Yq65NN QuVScUwNrLBLHzUyfFvtDDXVQcAKVQ/4XGFUS7VSMA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrjedtgdelgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefgffek udevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 800E21700089; Sun, 27 Nov 2022 11:51:19 -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: <38e576a2-a293-41b7-990f-9d4ecfad3b70@app.fastmail.com> In-Reply-To: References: Date: Sun, 27 Nov 2022 10:50:59 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments From: larry@garfieldtech.com ("Larry Garfield") On Sat, Nov 26, 2022, at 6:35 PM, Jordan LeDoux wrote: > On Sat, Nov 26, 2022 at 3:40 PM Deleu wrote: > >> >> As I think more about this, there's nothing about the current RFC in this >> code sample. What's breaking LSP here is the child class doing state >> modification, not PHP. To further expand that rationale, PHP allows us to >> create child classes. Whether that class will be LSP-safe or not is up to >> us, not up to PHP. >> >> However, the point still stands. Allowing child classes to break readonly >> will make it easier to build code that breaks LSP. The question then >> becomes: why is this being proposed and is it worth it? >> > > I cannot help but feel that the way `readonly` is being treated is going to > end up one of those things that is regretted. "Readonly does not imply > immutability". The fact that very nearly *every* single person who has not > worked on the RFCs has at some point been confused by this however should > be very telling. > > This comes from two *different* avenues that compound with each other to > *both* make this design head-scratching to me. > > First, in virtually all other technical contexts where the term "readonly" > is used, it means that the information/data cannot be altered. That is not > the case with readonly. In PHP, in this implementation, it is not > "readonly" in the sense that it is used everywhere else for computing, it > is "assign once". > > Second, the English words "read only", particularly to native speakers, > make this behavior very counterintuitive and confusing. I won't belabor > that point further. > > What "read only" really is, is "constructor initialize only". It honestly > has nothing to do with "read" as it's implemented. Not quite. It really is just write-once. The idea that you can only do that in the constructor is not in the language; that's been invented by over-eager static analysis tools. (Everyone should disable that check.) > I guess I worry that this RFC makes `readonly` even more of a minefield for > PHP developers, increasing the mental load of using it in code while *even > further* watering down the benefits it may provide. It's already designed > in a somewhat counterintuitive way that I feel will be almost completely > replaced in actual code in the wild by "immutable" if PHP ever gets that. Working on asymmetric visibility, I have come to agree. Nikita proposed readonly as a "junior version" of asymmetric visibility, to cover the most common use case without introducing more complexity. At the time, he was confident that it wouldn't preclude expanding to asymmetric visibility in the future. Well... I can say with confidence at this point that is not correct, and the design of readonly is causing issues for asymmetric visibility, and for cloning, to the point that (based on feedback in the other thread) we're likely going to for now forbid readonly and a-viz on the same property. At this point, I think I view readonly as a cautionary tale about the costs of doing "quick and easy" design over something more robust, because the quick-and-easy creates problems down the line that a more thoughtful, holistic view would have avoided. > LSP doesn't exist because it is some objectively better way of programming > according to universal laws of entropy or something. It is instead > important because LSP helps programmers be able to predict the behavior of > the program they are writing and reduces the short-term memory load > involved in programming and architecture. > > Something that *technically* complies with LSP but makes the program harder > to predict and increases the mental load of programming violates the > *purpose* of LSP. We can argue about whether it is technically correct, but > I feel like that somewhat misses the point: making the language more > capable, more stable, and more predictable. > > In other words, I do not believe it is that important or care to argue > about whether this RFC violates LSP. It violates the *purpose* of LSP, and > that's a bigger problem to me personally. > > Jordan At this point, I am inclined to agree. readonly is wonky enough as is. Making it semi-LSP (in spirit) just makes it even more wonky. To flip the earlier sentiment, "readonly is broken enough as is, let's not break it even further." --Larry Garfield