Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124198 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 CF3341A009C for ; Wed, 3 Jul 2024 14:23:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1720016668; bh=CzJz3gklqMJRPhMAAyK2M8KtRMajzNKbD1+Bql2Ag2Q=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=f3QGZjXnYvRrxDpkhxYWABu/DpT8QJnBfBH7ioBcwd0w3FD21AO+keyaxX+T7xWT0 SxbACcB6JWxKaW/6rCOAMQNwFY4J3GDfyJ5pIQ5W5Nuj2QjXK0q52YS8jrMjw0UPNg wHqNIDMpduNkXQdMJxSX3gg1cFuR99FW5sXctkihylz1pc3pHY4uOuij7m1yhC7AZq sKJnKIICjX5xQb9ouFlJS5RRfU6AI26Z+cRHgEfuBV/rv0mNEiVutd+e2viTLga9Rt QVum5DEUclrA9SVe8JoFBMZv3VaNMEb6YVkTdlAS7AwLw9/pNP8ksXy+s2A2vllEtr DlmJEetc8LY5Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 39E911807F2 for ; Wed, 3 Jul 2024 14:24:27 +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 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 ; Wed, 3 Jul 2024 14:24:26 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 615BF1140102; Wed, 3 Jul 2024 10:23:04 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute1.internal (MEProxy); Wed, 03 Jul 2024 10:23:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc: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=fm3; t=1720016584; x= 1720102984; bh=oep+gbN183M0F06W3/NvB96zrH3zWXJYAbc71pUCFGU=; b=e aiYyx9xW6e6owkvYZU9e+MFOsMNmiqiBsqLrDakfkJ1NhfcybqumQTMUmfegHHgC JYMPcTsDtaTuQhqULHbI9A9IsHamPemilOhtwRrgOco+ah3V7sYBKdhubKGi1iDK 1mFt3INpqzF8D8pZHAQu/lqBLlRbD/ZknJmivxyhHt/6T9qP4GhuT2cuFCtp/R81 xlCMv4E32Qd8247CVhPpWu71w7+cNCY+qzUr0/+moG1rkHcPK9zoEGxCuD3KRz8D T0WkKdcOiWYRtBYviKIQZ4d8DJrcEZTquwakeC28IsitDeW317T+3HLKRREE1bAE ZNJpmQ3mau2ESo18Zc3Ag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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= fm2; t=1720016584; x=1720102984; bh=oep+gbN183M0F06W3/NvB96zrH3z WXJYAbc71pUCFGU=; b=omFpQBpO0ijVtN6NWYrnaqfKXfiKUZd1WzOIo3kHdUZN gzTosQaIL7+dz6zr8NoCJxFu+oM2A7MyjdX38/T/9+AukZ3i4J5WWfc770O67k4f oc5FEI/8rhYS4fcbVeuRGUftIFFatTSVliAe0T/A8DLsOTgzk6rP6krVcjn1Lt/7 /MwUPJKGKppebyuC6t4xeoV9APRhbrtmkV6r8X4bvENZuG/I+qx6U8o3SXtBaJnR kySMojyr1/7Bx20oKcbqN48lTpMA8hDoiSgvBejByUnZguuD9QSbsZNYzJ/I8yQe TNkrPeYGyd6mVW9g2Df9QHI5koPEYKaJluYXiHesKg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudejgdejhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesrgdtreerreerjeenucfhrhhomhepfdftohgs ucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrg htthgvrhhnpedvheekteelveetfeevgeekgfffvdeuhfelveehvdetiefggedtfeejheet gffhueenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hrohgssegsohhtthhlvggurdgtohguvghs X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id F139715A0092; Wed, 3 Jul 2024 10:23:03 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-566-g3812ddbbc-fm-20240627.001-g3812ddbb Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <02de79f3-c323-4e54-ba26-e213d9b4c65d@app.fastmail.com> In-Reply-To: <063761C9-3DAE-4F3C-8279-F2B1636EF953@gmail.com> References: <8A3C2FDA-60DF-45A1-BA9D-11B6FB6F755C@gmail.com> <557008ce-30c4-4002-b731-1faabe487e64@app.fastmail.com> <063761C9-3DAE-4F3C-8279-F2B1636EF953@gmail.com> Date: Wed, 03 Jul 2024 16:22:42 +0200 To: "Claude Pache" Cc: "Larry Garfield" , "php internals" Subject: Re: [PHP-DEV] [RFC] Property Hook improvements Content-Type: multipart/alternative; boundary=c497a8c8a2ab4376838c449e81bd14e0 From: rob@bottled.codes ("Rob Landers") --c497a8c8a2ab4376838c449e81bd14e0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Jul 3, 2024, at 15:29, Claude Pache wrote: >=20 >=20 >> Le 3 juil. 2024 =C3=A0 14:42, Rob Landers a =C3=A9= crit : >>=20 >> On Wed, Jul 3, 2024, at 14:28, Claude Pache wrote: >>>=20 >>>=20 >>>> Le 3 juil. 2024 =C3=A0 11:54, Claude Pache = a =C3=A9crit : >>>>=20 >>>>=20 >>>> 2. As for readonly, I think that the invariant it is supposed to pr= ovide should be enforced as strictly as possible. It means that `readonl= y` is only acceptable if there is no `get` hook. >>>=20 >>> Hi, >>>=20 >>> One more thing, why I think that we should be strict here. It is not= just for preventing the user to write *dumb* code, it is also for preve= nting them to write *creative* code, e.g. >>>=20 >>> ```php >>> class doc { >>> public readonly int page { >>> get =3D> $this->page + $this->offset; >>> } >>> private int $offset =3D 0; >>> public function __construct(int $page) { >>> $this->page =3D $page; >>> } >>> public function foo() { >>> // $this->offset may be adjusted here >>> } >>> } >>> ``` >>>=20 >>> =E2=80=94Claude >>=20 >> I don't see anything wrong with that code. $page doesn't say "immutab= le" it says "readonly", as in "cannot write to". >>=20 >> =E2=80=94 Rob >=20 > The fact you don=E2=80=99t see anything wrong is *precisely* the issue= . According to the original RFC [1], the intention of readonly propertie= s was immutability, not just non-writability. For the weaker case of non= -writability, it was explicitly mentioned the possibility of (future) as= ymmetric property visibility. That was before properties could be functions? Now I suppose we have to = decide if the definition of read-only doesn't mean read-only, but immuta= bility; despite the original intention. >=20 > That said, I agree that =E2=80=9Cimmutable=E2=80=9D would have been a = better word choice than =E2=80=9Creadonly=E2=80=9D for conveying the ori= ginal intention. We could also ignore the original intention and reinter= pret the feature in case everyone agrees (personally, I prefer the origi= nal intention, but I won=E2=80=99t fight for that). Agree. I just wanted to point out that there were two interpretations: t= he English definition, and the original intention of the RFC. =E2=80=94 Rob --c497a8c8a2ab4376838c449e81bd14e0 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Wed, Jul 3, 2024, at 15:29, Claude Pache wrote:


Le = 3 juil. 2024 =C3=A0 14:42, Rob Landers <rob@bottled.codes> a =C3=A9= crit :

On Wed, Jul 3, 2024, at 14:= 28, Claude Pache wrote:


Le 3 juil. 2024 =C3=A0 11:54, Claude Pache <cl= aude.pache@gmail.com> a =C3=A9crit :


2. As for= readonly, I think that the invariant it is supposed to provide should b= e enforced as strictly as possible. It means that `readonly` is only acc= eptable if there is no `get` hook.

=
Hi,

One more thing, why I think that w= e should be strict here. It is not just for preventing the user to write= *dumb* code, it is also for preventing them to write *creative* code, e= .g.

```php
class doc {
    public readonly int page {
&nbs= p;       get =3D> $this->page + $this->offset;
    }
    private int $of= fset =3D 0;
    public function __construct(int = $page) {
        $this->page =3D $p= age;
    }
    public fu= nction foo() {
        // $this->of= fset may be adjusted here
    }
}<= br>
```

=E2=80=94Claude
=

I don't see anythin= g wrong with that code. $page doesn't say "immutable" it says "readonly"= , as in "cannot write to".

=E2=80=94 Rob

=
The fact you don=E2=80=99t see anything wrong is *precisely* = the issue. According to the original RFC [1], the intention of readonly = properties was immutability, not just non-writability. For the weaker ca= se of non-writability, it was explicitly mentioned the possibility of (f= uture) asymmetric property visibility.

That was before properties could be functions? Now I suppose we= have to decide if the definition of read-only doesn't mean read-only, b= ut immutability; despite the original intention.


That said, I agree that =E2=80=9Cimmutable=E2=80=9D wou= ld have been a better word choice than =E2=80=9Creadonly=E2=80=9D for co= nveying the original intention. We could also ignore the original intent= ion and reinterpret the feature in case everyone agrees (personally, I p= refer the original intention, but I won=E2=80=99t fight for that).

Agree. I just wanted to point out t= hat there were two interpretations: the English definition, and the orig= inal intention of the RFC.

= =E2=80=94 Rob
--c497a8c8a2ab4376838c449e81bd14e0--