Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122649 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 057371AD8F6 for ; Fri, 15 Mar 2024 23:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1710545162; bh=aoxjqXk0kZoMm9K0Ki/HTNHyFpSefXTyZSAtxCs1PJw=; h=Date:From:To:Subject:In-Reply-To:References:From; b=eDmmG/+oRg2OQtjbauJEXmrLQiihcLtaqyHFHRKWDpHZ3houWfI38uD22nuvIS5J5 d3IkzMLMbUIjTJZ/3Ax9sRQdTiCMgzvtaBz3e4herfAJhPyT4xUEC82QCPot86VmXL XsgsX0QUtlOzr8iCitnM5yV8DDhAbMlByAuuwDx8zjyxBOvw957iDBxMOqKbpEp4qP yiXHKs+pNbZBzSx9QhiVx45jQrXKov2qovPv7NgNmW59+y+ImLgH3l3kJNhXJqVpoT tpnCQXzA8tlJK739Y6K+AyuTDUa5NeTi0FrnbjboUvNev3HcjTfgNk5VDVJ7wZ7zdm iLgkaYbeBgphg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7D980180062 for ; Fri, 15 Mar 2024 23:26:01 +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_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from wfout4-smtp.messagingengine.com (wfout4-smtp.messagingengine.com [64.147.123.147]) (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 23:26:00 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfout.west.internal (Postfix) with ESMTP id 3C1871C000AF for ; Fri, 15 Mar 2024 19:25:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Fri, 15 Mar 2024 19:25:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; 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=fm1; t=1710545140; x=1710631540; bh=WeI7U7E0O4U/gfmXvDYhtIxW0ANAV8yHnTQ+WoYq10w=; b= qJ+0LZUBQ3wJjLD67BPlBPMAXDAOQvCyK+2Xn5vVdBaagJP2P9/i5JtVElzwzhGw Yp5z/it1Jxzxy+xIsWiVML1iMhPUO+y8rlN+ZkIWnjrWpXOE2ntq6h/X7JxAPOUO pq9jkkhwEMETqUW0fw+H9sQwNmw4zpSwFO7cGsFLxCBq+imhzcli7/SUD6MJzqPY G5XJVUm5RgzBWU5VoZ5JOmqqP8zvAlwwDWpkVP3WzaoLy3K7h61+1Xei3U3ISM5q m5FHsuVCGV0tTj17PPPETMbTheZTsEWfzrd0mGOUec/aeSlks8uuXhj7RNNavy4p K+O3kPuIngawgRhRB0H7eQ== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1710545140; x= 1710631540; bh=WeI7U7E0O4U/gfmXvDYhtIxW0ANAV8yHnTQ+WoYq10w=; b=g rxsv2j6pgfl5LiHW9I12YMintenLHsWktsfXh27U4QnHamL9WKI+iIuUNf9dDwX3 3rBZR8tHuhHHaPMl7IHApJJlOEhuxyRPp2mhgOgZA4Ul9iyGrbXPuBJTbHe/rJi9 SRnJ7YuTMDyn2lHiP5KAkTyKG1mp46oYzXOaGpsEImh6NE5otnVRBcBXItKl+gcu bGFr/kEFErE/BbRlH4F3OT+qMlnU186qPCTWSnFYhhT4+R0EJrbjroKyMktC4hJ8 10h3LKR759Lx2+UcHzwdT4iT4a933MbGw1JKv30OnqNKQf0Y2nK+h1TEWiVAv0Ku +jCQb887U+0sXXcmy5pmg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrkedtgddtlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffufggjfhfkgggtgfesthhqmh dttderjeenucfhrhhomhepfdftohifrghnucfvohhmmhhinhhsucglkffoufhorfgnfdcu oehimhhsohhprdhphhhpsehrfigvtgdrtghordhukheqnecuggftrfgrthhtvghrnhephe elffetiefgveduteefudegtdduveeludegueegleehiefhhefgtdekveevgfelnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhmshhophdrph hhphesrhifvggtrdgtohdruhhk X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 15 Mar 2024 19:25:39 -0400 (EDT) Date: Fri, 15 Mar 2024 23:25:37 +0000 To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC[ Property accessor hooks, take 2 User-Agent: K-9 Mail for Android In-Reply-To: <154481e0-5f62-4026-994a-28a644d71527@app.fastmail.com> References: <7eada0fd-39c5-4a89-8c74-80c671801a2d@app.fastmail.com> <1698692e-8eb1-4bfc-a743-375696cd8f1c@rwec.co.uk> <154481e0-5f62-4026-994a-28a644d71527@app.fastmail.com> Message-ID: Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 15 March 2024 17:11:29 GMT, Larry Garfield w= rote: >On Wed, Mar 13, 2024, at 10:26 PM, Rowan Tommins [IMSoP] wrote: >> I think it would be more helpful to justify this design on its own=20 >> merits, particularly because it's a significant difference from other= =20 >> languages (which either don't have a "real property" behind the hooks,= =20 >> or in Kotlin's case allow access to it only *directly* inside the hook= =20 >> definitions, via the "field" keyword)=2E > >I'm not sure I follow=2E The behavior we have currently is very close to= how Kotlin works, from a user perspective=2E Unless I'm misunderstanding something, the backing field in Kotlin is acce= ssible only inside the hooks, nowhere else=2E I don't know what would happe= n if a hook caused a recursive call to itself, but there's no mention in th= e docs of it bypassing the hooks, only this: > This backing field can be referenced in the accessors using the `field` = identifier and > The `field` identifier can only be used in the accessors of the property= =2E And then a section explaining that more complex hooks should use a separat= e backing property - which is the only option in C#, and roughly what peopl= e would do in PHP today with __get and __set=2E Kotlin does have a special syntax for "delegating" hooks, but looking at t= he examples, they do not use the backing field at all, they have to provide= their own storage=2E >I've lost track of which specific issue you have an issue with or would w= ant changed=2E The guards to prevent an infinite loop are necessary, for t= he same reasons as they are necessary for __get/__set=2E I understand that *something* needs to happen if a recursive call happens,= but it could just be an error, like any other unbounded recursion=2E=20 I can also understand the temptation to make it something more useful than= an error, and provide a way to access the "backing field" / "raw value" fr= om outside the hook=2E But it does lead to something quite surprising: the = same line of code does different things depending on how it is called=2E I doubt many people have ever discovered that __get and __set work that wa= y, since as far as I can see it's only possible to use deliberately if you'= re dynamically adding and unsetting properties inside your class=2E So, I don't necessarily think hooks working that way is the wrong decision= , I just think it's a decision we should make consciously, not one that's o= bvious=2E =20 =20 Regards, Rowan Tommins [IMSoP]