Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122661 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 8AFD61AD8F6 for ; Sat, 16 Mar 2024 19:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1710616994; bh=Z5YnM2yhK90t1kSiZqWklnDHkAnIyI5euvS8J/7JcJ0=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Z6EUvYfQXQdPaLVVNRjoS9okgGF3YXEii4MOMa3NpRPPtigxukEJGgcGnzyPoJN/5 j+jnH1itNWLB0BLFdjuPKCZAfmH+exWid8e1T3d/ILfYB6ICyKB8H28337xIS9daNF mVmcvmiUVgJRzuhQoV5UEv1i8Ox8YyjGt8QUI1iQFU6GwHcxf2XQKNmFSw69wvlMDB zhzXkRf7jExlHryJ3V2KkaKaJJVK3jJhO5necRIifHVbjEdh5/ZhQZPvARZ/RYUhc+ 9ToK3iQ6CbLFEJBn22oyloY+ZSYh+RX3JTSpIF6ECpKzdC7JJjuWaxm7C6eqQhxQEW o/t0l+q767J2w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 02AAC180004 for ; Sat, 16 Mar 2024 19:23: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,HTML_MESSAGE, 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 fhigh5-smtp.messagingengine.com (fhigh5-smtp.messagingengine.com [103.168.172.156]) (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 ; Sat, 16 Mar 2024 19:23:10 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id ACE1811400B3 for ; Sat, 16 Mar 2024 15:22:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sat, 16 Mar 2024 15:22:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; 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=1710616970; x=1710703370; bh=fPvzyEv6TU CVY7jz+W/aBeLWMiW401jU2gEdiqlBt+8=; b=S3yOIcvvPHAoOPNSf40EdEGeXk he4fj8gEZszfIapaoZkEugv6pilmNDuwv5N5iJQ9SiLNkiPVHWEXOnhTQmvjCHvD e8ZmahHyfiP5Ogk0eAr4d7ZfbGoP/vygxUco6cC+Ub0SARlDx3if/N35BJp8sU4I D/6MQ3ZvfQCnlDUvONOEW+Cfaejo0SvBZMHxs31S8tHzaui7PBzOvTBwjsC8LCWR f649Z4FJoXzh9M4OmSxuIGCnv5u8z1rcwbFtixvKvpW6+e0qGLw4fNS1uqizwzgU cZLnwin9ad3yJOaxqzzkdISoaORkAMtR95eQyYZFKQvzIpb0rdBv82NqVR/A== 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=1710616970; x=1710703370; bh=fPvzyEv6TUCVY7jz+W/aBeLWMiW4 01jU2gEdiqlBt+8=; b=fbPVdPF5oYuwwBvynuIBy4uWF1Eox7a1VmW1l3qiWBI5 XxHNL4qWdKHAzFHfC0BkerCR8tRBpfx6ciAqLm37NdDKk0zoTAJI4xDITNo5E41E X0anorH+R+2vpZG9UsO/OvV67IoOo4vm4PzzdnnyKnSBPMMfVWAc7QU1LxLORSmc TB8HxF68ZL7agVN9+Ma1hgjomuVS5Syi9HsJv+f32qNNzHvacd+DgidZkcX4+4d0 BvO8D4Py7xSEoM1+dSAFhUP+jR4Al5oOBf6PuvdJVxOlx+uEF4GoCH3dI5a62iN5 uOpVmmro4O3HhKjKXVOx5gOm2CZnMjqyfPK+YiwKpQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrkedvgddutddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpegtkfffgggfuffvfhfhjgesrgdtre ertddvjeenucfhrhhomhepfdftohifrghnucfvohhmmhhinhhsucglkffoufhorfgnfdcu oehimhhsohhprdhphhhpsehrfigvtgdrtghordhukheqnecuggftrfgrthhtvghrnhephe etleeiiefgueduieeuieffvdevheduueefkeejuefgffeftdeitdegtedtleetnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhmshhophdrph hhphesrhifvggtrdgtohdruhhk X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sat, 16 Mar 2024 15:22:50 -0400 (EDT) Content-Type: multipart/alternative; boundary="------------pstL870mxy142bejb5Zclpri" Message-ID: Date: Sat, 16 Mar 2024 19:22:42 +0000 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC[ Property accessor hooks, take 2 To: internals@lists.php.net 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> <46609F15-DD40-4BD2-A78A-16021C3447C8@rwec.co.uk> Content-Language: en-GB In-Reply-To: From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") This is a multi-part message in MIME format. --------------pstL870mxy142bejb5Zclpri Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 16/03/2024 17:51, Ilija Tovilo wrote: > Properties can inherit both storage and hooks from their parent. > Hopefully, that helps with the mental model. Of course, in reality it > is a bit more complicated due to guards and references. That is a really helpful explanation, thanks; I hadn't thought about the significance of inheritance between hooked and non-hooked properties. I still think there will be a lot of users coming from other languages, or from using __get and __set, who will look at virtual properties first. Making things less surprising for those people seems worth some effort, but I'm not asking for a complete redesign. > Dynamic properties are not particularly relevant today. The point was > not to show how similar these two cases are, but to explain that > there's an existing mechanism in place that works very well for hooks. > We may invent some new mechanism to access the backing value, like > `field = 'value'`, but for what reason? This would only make sense if > the syntax we use is useful for something else. However, given that > without guards it just leads to recursion, which I really can't see > any use for, I don't see the point. I can think of several reasons we *could* explore other syntax: 1) To make it clearer in code whether a particular line is accessing via the hooks, or by-passing them 2) To make the code in the hooks shorter (e.g. `$field` is significantly shorter than `$this->someDescriptiveName`) 3) To allow code to by-pass the hooks at will, rather than only when called from the hooks (e.g. having a single method that resets the state of several lazy-loaded properties) Those reasons are probably not enough to rule out the current syntax; but they show there are trade-offs being made. To be honest, my biggest hesitation with the RFC remains asymmetric types (the ability to specify types in the set hook). It's quite a significant feature, with no precedent I know of, and I'm worried we'll overlook something by including it immediately. For instance, what will be the impact on people using reflection or static analysis to reason about types? I would personally be more comfortable leaving that to a follow-up RFC to consider the details more carefully. Nobody else has raised that, beyond the syntax; I'm not sure if that's because everyone is happy with it, or because the significance has been overlooked. Regards, -- Rowan Tommins [IMSoP] --------------pstL870mxy142bejb5Zclpri Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
On 16/03/2024 17:51, Ilija Tovilo wrote:
Properties can inherit both storage and hooks from their parent.
Hopefully, that helps with the mental model. Of course, in reality it
is a bit more complicated due to guards and references.


That is a really helpful explanation, thanks; I hadn't thought about the significance of inheritance between hooked and non-hooked properties.

I still think there will be a lot of users coming from other languages, or from using __get and __set, who will look at virtual properties first. Making things less surprising for those people seems worth some effort, but I'm not asking for a complete redesign.



Dynamic properties are not particularly relevant today. The point was
not to show how similar these two cases are, but to explain that
there's an existing mechanism in place that works very well for hooks.
We may invent some new mechanism to access the backing value, like
`field = 'value'`, but for what reason? This would only make sense if
the syntax we use is useful for something else. However, given that
without guards it just leads to recursion, which I really can't see
any use for, I don't see the point.


I can think of several reasons we *could* explore other syntax:

1) To make it clearer in code whether a particular line is accessing via the hooks, or by-passing them 2) To make the code in the hooks shorter (e.g. `$field` is significantly shorter than `$this->someDescriptiveName`) 3) To allow code to by-pass the hooks at will, rather than only when called from the hooks (e.g. having a single method that resets the state of several lazy-loaded properties)

Those reasons are probably not enough to rule out the current syntax; but they show there are trade-offs being made.

To be honest, my biggest hesitation with the RFC remains asymmetric types (the ability to specify types in the set hook). It's quite a significant feature, with no precedent I know of, and I'm worried we'll overlook something by including it immediately. For instance, what will be the impact on people using reflection or static analysis to reason about types? I would personally be more comfortable leaving that to a follow-up RFC to consider the details more carefully.

Nobody else has raised that, beyond the syntax; I'm not sure if that's because everyone is happy with it, or because the significance has been overlooked.


Regards,

-- 
Rowan Tommins
[IMSoP]
--------------pstL870mxy142bejb5Zclpri--