Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122647 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 qa.php.net (Postfix) with ESMTPS id 456C11AD8F6 for ; Fri, 15 Mar 2024 17:11:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1710522732; bh=NvSAjELJAeD6alzceYKmhw+UuF/IfmHhN49SM5iMBWw=; h=In-Reply-To:References:Date:From:To:Subject:From; b=AVAtk5w2p2Yn8y66pfjScvQHmRdU5lksLQ7kEWw4GBAVc8prZtVw9ZtTUdPprXDXa vNEFR/jxFUZJB9eDoy5YF/IgtsUf1WR3OO3ebpwGEtl26BxL2zt1y+aHJA3D2ZVqJb FTSKBILgBi4TsIvxlViA+6vmHFOp49GMvl2lSCBu/M4+2zmnYyD+m4RNOzpylkIXr0 xSJpRCmOq1xmLKgJD00GoPQCEBkY4hHuT4h0lTna8zpiqNwMdiOfUZhgaK4/S0yDA7 as6hsVu/kLCTYH2T0q+XChsIfYeeALMy8acxZjPv9E+w1FWJih092D+VMLfn+cy3wl aer7WUwwDyovw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D4807180070 for ; Fri, 15 Mar 2024 17:12:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 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 X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 15 Mar 2024 17:12:11 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 96C9C3200063 for ; Fri, 15 Mar 2024 13:11:50 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Fri, 15 Mar 2024 13:11:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc: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=fm1; t=1710522710; x= 1710609110; bh=7GugYdzLz+FYZH+nbLo2wZgv0iWPDxXxU+1g/i4VCw0=; b=e uMkGlRXDYyVousZCt2RTx8+3ITF4HYj/XD2SPpm8vrnX0+bvReoHLftSITuDQ8lT zmThWqF1dkyLR+1/KIm09f3+oRV+fjnbTUutUVnAw+8XQ0b7IxhqvVFDtbbtBzMt KdSwlN+pSv7RaDioUrHx30POnd/SuOVDH38ZOM8lI2vtO5YSQS65ewWjWE/Cn43T 78R6fPHF1cX/KzL6kStHMgElOWOUTfyNPx7VXiO2lVpuKEPiUaF87mf9MIkB4q/I d2yLBa32wEwlvMS2gYOxHxq2egVyQ1tA6ALP+33wkiRWxzNlWrJyNb/Ml7nUgKDa wsm2YrTO/vwOIDVHNaAPw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1710522710; x=1710609110; bh=7GugYdzLz+FYZH+nbLo2wZgv0iWP DxXxU+1g/i4VCw0=; b=KnPyRjbYPxrQygi3lOsmkJk+e5Hab/+4eb63ruj6dsLB 5m+ibPjTMiwHbkXzeaxvGwnkLXBzrr1HuzJnks7sQu/v72xaXGnUlbVK2NXori5y Zi17BkvV0i7MDVO1gDVe1Y1RWBnAsS5VfLWZ+7JOsnVoi4gb3HQgrkp/8xQFiVZB iwfp71Aic2PXC5t+7o7y2ZFKLiNZoOy3HhamuMx3OwIv7S5igbqTMnnhJkLLIE+j JFFVageFohrbd8912IFaTec8GnBAgFXq9srNw7FvsrQHpDyD4rC7NEG/46+drbqs txSeUQh75c3t2FeAAz7xm8Zr+HqYeV63eT4RBger8Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrjeelgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnhepfeelueeltdfggeevheekgffhhedtkeetteeggeefudek vefhueeikeelhfdtheeunecuffhomhgrihhnpeefvheglhdrohhrghenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhi vghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id AA1751700096; Fri, 15 Mar 2024 13:11:49 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-300-gdee1775a43-fm-20240315.001-gdee1775a Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <154481e0-5f62-4026-994a-28a644d71527@app.fastmail.com> In-Reply-To: <1698692e-8eb1-4bfc-a743-375696cd8f1c@rwec.co.uk> References: <7eada0fd-39c5-4a89-8c74-80c671801a2d@app.fastmail.com> <1698692e-8eb1-4bfc-a743-375696cd8f1c@rwec.co.uk> Date: Fri, 15 Mar 2024 17:11:29 +0000 To: "php internals" Subject: Re: [PHP-DEV] [RFC[ Property accessor hooks, take 2 Content-Type: text/plain From: larry@garfieldtech.com ("Larry Garfield") On Wed, Mar 13, 2024, at 10:26 PM, Rowan Tommins [IMSoP] wrote: > On 12/03/2024 22:43, Larry Garfield wrote: >> It's slightly different, yes. The point is that the special behavior of a hook is disabled if you are within the call stack of a hook, just like the special behavior of __get/__set is disabled if you are within the call stack of __get/__set. What happens when you hit an operation that would otherwise go into an infinite loop is a bit different, but the "disable to avoid an infinite loop" logic is the same. > > > I guess I'm looking at it more from the user's point of view: it's very > rare with __get and __set to have a method that sometimes accesses the > "real" property, and sometimes goes through the "hook". Either there is > no real property, or the property has private/protected scope, so any > method on the classes sees the "real" property *regardless* of access > via the hook. > > I think it would be more helpful to justify this design on its own > merits, particularly because it's a significant difference from other > languages (which either don't have a "real property" behind the hooks, > or in Kotlin's case allow access to it only *directly* inside the hook > definitions, via the "field" keyword). I'm not sure I follow. The behavior we have currently is very close to how Kotlin works, from a user perspective. (The internal implementation is backwards from Kotlin, but that doesn't matter to the user.) I've lost track of which specific issue you have an issue with or would want changed. The guards to prevent an infinite loop are necessary, for the same reasons as they are necessary for __get/__set. We couldn't use a backing field otherwise, without some other syntax. (This is where Kotlin uses 'field'.) So, I'm not really sure what we're discussing at this point. What specific changes are you suggesting? >> With the change to allow &get in the absence of set, I believe that would already work. >> >> cf: https://3v4l.org/3Gnti/rfc#vrfc.property-hooks > > > Awesome! The RFC should probably highlight this, as it gives a > significant extra option for array properties. Updated. I may try to rewrite the array and references section this weekend, as with the changes in the design to be more permissive I'm not sure it's entirely clear anymore what the net result is. --Larry Garfield