Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127997 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 8BC741A00BC for ; Thu, 10 Jul 2025 15:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1752161568; bh=329KYjRChystrP14R5U04b/4V588nK08ucBefBiJQfg=; h=Date:From:To:In-Reply-To:References:Subject:From; b=SWQIJpaxGHgWmZiU8bu2y0wROlHeraYKiaX3bfner/PaIUXj22RlIw3mzXH7xDbSV DWs/TzTzwdJDs7kq9JbFBmI3cKpecbSZZ1dDipoIPxEvQevFfK+/nIFu3D2yusSQQD RIiB0HIFf/SXdJK5VEIqBm70mLA5wXDls6tdfureN2Cy6uevyyvzL3EAUKOgo8sW0F 8HZyStpw6V26c+srWzhB2R5YN9a3moU9igTWcpLMES9kDqGruOKNAOYPjX1a6MHdP5 hX1erOk5y5MjXpL0/kwxf5bAtNq24renQRt5ru74zpyhJUp3BBlLAbnWset5Norifq N0BPWiwCXIZ8Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 99A0318005B for ; Thu, 10 Jul 2025 15:32:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fout-a1-smtp.messagingengine.com (fout-a1-smtp.messagingengine.com [103.168.172.144]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 10 Jul 2025 15:32:47 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id 4ED5DEC0237 for ; Thu, 10 Jul 2025 11:34:36 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Thu, 10 Jul 2025 11:34:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm2; t=1752161676; x=1752248076; bh=91KFvJn54bADg8SL329gN ID8+X7SV6t598ofwhV6JGU=; b=SLyMt+aXO0unvtki7jR90JVYrYjCPZTYqENof 3qDX4p824qWSuwNIZSqmHilKky9+GeTzJKqL0ML//v6r7GnT0+HpM6DRjuTFrCN0 ridfzkiZT6z4BP4doylE8Xx93hfPtbynkKvzWmrJVwN+65wSVM89tPKl7jzicjmc ujYb0bTi5yD57OU7k8TgZW4dXHoKjDHAXW7S4kqlSfr+ctJSr02DPa3iUWQYtFKc 6ySA1PWKaXd2DXDSU4tmzqJdb2dFtq1SSUI/ikUzCP1eTurBC6ih9v/oD0t+wVFE E1n/Entta44JGQl+n+nylaTqd/2s3q9zVk/928r4DFfa9ErOA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1752161676; x=1752248076; bh=9 1KFvJn54bADg8SL329gNID8+X7SV6t598ofwhV6JGU=; b=j1ws87X6d9YK4+HdP go2vEeCuCSHWJiaFdzYP0EFovukVH+bjuBXqDqd0acn+LDYvKoDCCFiROJrVwIE9 QFur5yHaZUXEolrwO2lLLmGg1i4VdAkkVgFwdql1+xfFFtBM38bcFnn1vFDPjzEx arHL5E3H4KZwp0Ugmv78sp34pjNqHvMwm+/dAR5k1S3ESMTtc3/ewNMjDk16SMhR Y+joFEuwpFt+X0jioQCkPx+CkPDTILReKvwhUF8qXdV1TDFN4OEV1MwwjTs9W5cm aD0ZG7s76TfzbRAyyduxKLSiOQbLt0lcSkMJplIiJr2QJkySdIC+XcayBqAOj1JK ORrDA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdegtdekudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvkfgjfhfutgfgsehtqhertdertdejnecuhfhrohhmpedfnfgrrhhrhicu ifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqne cuggftrfgrthhtvghrnhepffeiiedvhfdvgedutddtgeetieeugeevhfetheeffeeftedu iedthedtgeejueeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphht thhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhsse hlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id C33F2700065; Thu, 10 Jul 2025 11:34:35 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: Taa1a9d92243b6726 Date: Thu, 10 Jul 2025 10:34:15 -0500 To: "php internals" Message-ID: In-Reply-To: <6acab95a554fe5e188364840ea36d2b7@bastelstu.be> References: <1e8634d7-ac1a-4025-b4e2-1948aabf5251@app.fastmail.com> <6acab95a554fe5e188364840ea36d2b7@bastelstu.be> Subject: Re: [PHP-DEV] [RFC] Readonly property hooks Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Thu, Jul 10, 2025, at 5:43 AM, Tim D=C3=BCsterhus wrote: > Hi > > Am 2025-07-08 17:32, schrieb Nicolas Grekas: >> I also read Tim's argument that new features could be stricter. If one >> wants to be stricter and forbid extra behaviors that could be added by >> either the proposed hooks or __get, then the answer is : make the cla= ss >> final. This is the only real way to enforce readonly-ness in PHP. > > Making the class final still would not allow to optimize based on the=20 > fact that the identity of a value stored in a readonly property will n= ot=20 > change after successfully reading from the property once. Whether or n= ot=20 > a property hooked must be considered an implementation detail, since a=20 > main point of the property hooks RFC was that hooks can be added and=20 > removed without breaking compatibility for the user of the API. > >> engine-assisted strictness in this case. You cannot write such code i= n=20 >> a >> non-readonly way by mistake, so it has to be by intent. > > That is saying "it's impossible to introduce bugs". > >> PS: as I keep repeating, readonly doesn't immutable at all. I know th= is=20 >> is >> written as such in the original RFC, but the concrete definition and >> implementation of readonly isn't: you can set mutable objects to=20 >> readonly >> properties, and that means even readonly classes/properties are=20 >> mutable, in >> the generic case. > > `readonly` guarantees the immutability of identity. While you can=20 > certainly mutate mutable objects, the identity of the stored object=20 > doesn't change. > > Best regards > Tim D=C3=BCsterhus Nick previously suggested having the get-hook's first return value cache= d; it would still be subsequently called, so any side effects would stil= l happen (though I don't know why you'd want side effects), but only the= first returned value would ever get returned. Would anyone find that a= cceptable? (In the typical case, it would be the same as the current $t= his->foo ??=3D compute() pattern, just with an extra cache entry.) --Larry Garfield