Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123563 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 B6CED1A009C for ; Sun, 9 Jun 2024 14:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717944557; bh=HCta9CLuz++frEcxmzbS/Qyhio0S2TQnHmzHCkHIGSk=; h=In-Reply-To:References:Date:From:To:Subject:From; b=iOHjTpuktLRYaFRDTfTEiEHkGJnLbRk/dsQDssZ9L+9C+ig+dtKu2do39U+4WpT2U 2dIteopJhYuU8pBmHJiI7y7IrGeISVBPKCDN8X095SyR0/JxOtG5YVw5tsHz29/IB4 3bZ+fmmzNn08sjK2INRktg4P+XvKPka5f10qUCGinuv011w2Kw5JempJODSp+3gdCm LblvnjxkOSJKeZY6Uve5cA4tOVQvwRx9Sf8uIbP9tGq5OQXeaXEbxM8bdOLDvmJFgW 6HjUTTfCS0h2nqn/Uv2+Dwi3x9Xfom55wx6BjmrPIn7JcogWC43zDklfAov8IWtRKn uCqsN6njdx4Ew== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2155C18005C for ; Sun, 9 Jun 2024 14:49:16 +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_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh3-smtp.messagingengine.com (fhigh3-smtp.messagingengine.com [103.168.172.154]) (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 ; Sun, 9 Jun 2024 14:49:15 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 122E4114014E; Sun, 9 Jun 2024 10:48:08 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute4.internal (MEProxy); Sun, 09 Jun 2024 10:48:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=npopov.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=fm2; t=1717944488; x=1718030888; bh=08oB1Gm6V+ fn6ib/IYFlOcdZBsPug9lOzqsum0wJio0=; b=dcMDQltxoVBwxN6/9/JFq0yXgY ctP/BuMkt9FQ/tv0P7z3gddxk94FAVbVMEwWB34gvCOrrGMNGBkxkkzidFLsW/U3 k1xROehT3MWhUzkUaHor13Fr2zB76XFwtPvLVblDbXddONfW2N1PyYtIdsd0o0VW TgUqlC6b6qVkr0DwJ8YvTtrYvnhWJRSXWk9K6z63lEFMOP2z3Qqe6O5iMvbeWbYZ mUjQUXP74OZouDOWsK2Ymb1y1H0ARWYOq4fbRdx20uagNhcqEr+voK4caLi4X4pc 7xnd+S3nN1mg+O/S5lZPlxysJ3jtvVnpUlroUSu8o3YLUlMhp09D5D9UBt5g== 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=1717944488; x=1718030888; bh=08oB1Gm6V+fn6ib/IYFlOcdZBsPu g9lOzqsum0wJio0=; b=H0mwtqMQalCU//U95hg8d+3y1qKDFlGsgnhrKWKJykMZ epT9air5YnDLUQNKT2nfElmZpXdxbXibuAxWyAXnSyYQGRjQ9HzjoRynS1z3OxAv Xa8pHPCSna+0hrBth0gUwbWygu5gYaAU2oHe62EksYNiAtUNDNPWps+S9vJIkLEw +ukqkhnXWTUgO8p7qTfUyBWgZxDzdRP1ru+sXGWJ+jXaax+W0auL7789KjozIqy3 jtWO33L0JGKkNaW/J8IU5Uq9fnRyFUNaEYCKgovFAzsPjKggBEp96by3Z03+g2Gm nXRDYX9WO8HpuA0fotI2+6JJPr5NqFkbmrAQZenM+w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedtjedgjeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesrgdtreerreertdenucfhrhhomhepfdfpihhk ihhtrgcurfhophhovhdfuceophhhphesnhhpohhpohhvrdgtohhmqeenucggtffrrghtth gvrhhnpefgjeeiveetfeffgfdtiedtfeefkeekueeggfehkeelhefhgeeufeehveevtdei udenucffohhmrghinhepphhhphdrnhgvthenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehphhhpsehnphhophhovhdrtghomh X-ME-Proxy: Feedback-ID: i9169476b:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 875AB31A0065; Sun, 9 Jun 2024 10:48:07 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-497-g97f96844c-fm-20240526.001-g97f96844 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <834cb6c7-c6ae-4b59-b022-a43793f842a3@app.fastmail.com> In-Reply-To: References: Date: Sun, 09 Jun 2024 16:46:16 +0200 To: "Larry Garfield" , "PHP internals" Subject: Re: [PHP-DEV] [RFC][Vote] Property Hooks Content-Type: multipart/alternative; boundary=2cfcd4e645d946f5952a4142eb2bacc4 From: php@npopov.com ("Nikita Popov") --2cfcd4e645d946f5952a4142eb2bacc4 Content-Type: text/plain On Mon, Apr 15, 2024, at 18:43, Larry Garfield wrote: > The vote for the Property Hooks RFC is now open: > > https://wiki.php.net/rfc/property-hooks > > Voting will close on Monday 29 April, afternoonish Chicago time. I know I'm a few months late on this one, but I figured I'd still leave a couple of thoughts... Overall, the proposal is well thought out and does address many of the reservations I had about my original accessors proposal. One of the more interesting choices in this proposal is to base whether the property is virtual or backed on the presence of a "$this->prop" reference in the accessor implementation. I think that, conceptually at least, this is a good choice. What I find concerning though, is that the presence/absence of such a reference also affects the meaning of the get and set hooks. If the property is virtual and it only has get, then the property cannot be set. If the property is backed and only has get, then the property *can* be set. A no-op setter is implied. (Similar for only having a set hook.) This has the unfortunate consequence that you actually have to look at the accessor implementation to determine the API of the class -- only looking at the "prototypes" (i.e. signatures without implementation bodies) is no longer sufficient! This seems both unfortunate and unprecedented. This could have been avoided by still requiring an explicit no-op "set;" at the expensive of some additional verbosity. The other thing that stood out to me are the short-hand notations using =>. There was a prior RFC on the topic (https://wiki.php.net/rfc/short-functions), which has been declined. That RFC would have introduced => ... as a general shorthand for { return ...; }. The shorthand notation for get is compatible with that formulation. However, the shorthand notation for set is not. In that case => ... isn't short for { return ...; }, but rather for { $this->prop = ...; }. This seems pretty unfortunate to me, and possibly closes the door on revisiting a general short function syntax in the future. Mostly I'm scratching my head at why this was included in the proposal at all, as I would not expect this use of the set hook to be common enough to justify a shorthand. The common case is a guard that checks the value without modifying it. Putting this to the "would this shorthand have passed if it were introduced by a separate RFC on top of the base implementation" test, I think the answer would have been a clear "no". Regards, Nikita --2cfcd4e645d946f5952a4142eb2bacc4 Content-Type: text/html Content-Transfer-Encoding: quoted-printable
On Mon, Ap= r 15, 2024, at 18:43, Larry Garfield wrote:
The vote for the Property Hooks RFC is = now open:

=

Voting will close on Monday 29 April, afternoonish C= hicago time.

I know I'm a few = months late on this one, but I figured I'd still leave a couple of thoug= hts... Overall, the proposal is well thought out and does address many o= f the reservations I had about my original accessors proposal.
=

One of the more interesting choices in this proposal= is to base whether the property is virtual or backed on the presence of= a "$this->prop" reference in the accessor implementation. I think th= at, conceptually at least, this is a good choice.

What I find concerning though, is that the presence/absence of su= ch a reference also affects the meaning of the get and set hooks. If the= property is virtual and it only has get, then the property cannot be se= t. If the property is backed and only has get, then the property *can* b= e set. A no-op setter is implied. (Similar for only having a set hook.)<= br>

This has the unfortunate consequence that y= ou actually have to look at the accessor implementation to determine the= API of the class -- only looking at the "prototypes" (i.e. signatures w= ithout implementation bodies) is no longer sufficient! This seems both u= nfortunate and unprecedented.

This could ha= ve been avoided by still requiring an explicit no-op "set;" at the expen= sive of some additional verbosity.

The othe= r thing that stood out to me are the short-hand notations using =3D>.= There was a prior RFC on the topic (https://wiki.php.net/rfc/short-functions), which h= as been declined. That RFC would have introduced =3D> ... as a genera= l shorthand for { return ...; }.

The shorth= and notation for get is compatible with that formulation. However, the s= horthand notation for set is not. In that case =3D> ... isn't short f= or { return ...; }, but rather for { $this->prop =3D ...; }.

This seems pretty unfortunate to me, and possibly c= loses the door on revisiting a general short function syntax in the futu= re. Mostly I'm scratching my head at why this was included in the propos= al at all, as I would not expect this use of the set hook to be common e= nough to justify a shorthand. The common case is a guard that checks the= value without modifying it.

Putting this t= o the "would this shorthand have passed if it were introduced by a separ= ate RFC on top of the base implementation" test, I think the answer woul= d have been a clear "no".

Regards,
Nikita
--2cfcd4e645d946f5952a4142eb2bacc4--