Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123559 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 CD8CB1A009C for ; Sat, 8 Jun 2024 08:50:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717836678; bh=nBGTSs97nHCRAcXNhKFC4xt6yTtMEWKtYODWdgYHVz4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ML6EB4uqOpdGIuHvfjqzxykgtRMd4TKMBgwR+xDtB9pKokV+ARDelEP8SFbQrphfd oMyz8Q0I14GvryKxUPEMggma+o/xkia3Ko6CRkP/SnkH8NeDZseKum3qolq/WUo7le dnaD4GdXZXaQYEyDqFYCfFPadKK6pKBKAgeH1LZr9tMytcRJZ9WvuyqM/1tDxhQXTR FZCGwRsf5ZJARoEQ/GkqFfHz3UzXAEZpF7CcKryQCY7ncWJKwN/vm+8xqrpRqXGkUG KSQtSYX1pU3zUY3wlnxdB6yzEVCc/jN2V1v9RdEJThpPXAnxOgjWu+ohd/FzZBt6QW X7IVYZVq50Hvg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6270E18003C for ; Sat, 8 Jun 2024 08:51:17 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, 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 mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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, 8 Jun 2024 08:51:16 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-35f0d6255bdso911967f8f.1 for ; Sat, 08 Jun 2024 01:50:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717836609; x=1718441409; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=+9l68oN/1vto5Ks+zxUd7mqPD/3oU/XrHZ7/41Xjj0k=; b=QhPDW3TOMy2qh5+6ztQ1tFqKjztM9jJvS/PCFnJip8hLXHTktejqu+bAMBtYyWNtCx F/7dn/P1m6AOJHP4Ik9SBATiHPACzf+AWRYnzDnaU+pfbq/XyEN4kYeCPqYBdvbd0aEP PIA+YEHis3UqFYsfMuyNkvkQ7npa63LSKRipEkXk63x6ybVOmF4HWeEV1Icw8P0KcyZx 2gtwIJXTFfkKAyQ1mwizXPxHpuYsuJUq4X/Dd5mdAc3Xq0nYP/nof8FeZ8fJT7UjmktE BabNr+leXr9d4ez4Iy044TAeIy4B5ngaq0EKJeJgIBzN32l6LcgtRq3HFDp/Y4DSQQL+ Fxyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836609; x=1718441409; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+9l68oN/1vto5Ks+zxUd7mqPD/3oU/XrHZ7/41Xjj0k=; b=XKEpC9T4RQFdcqtbS30vPfLQuA+djJ1xJ63gdVCRRZUQbOficuJ3aksjrkX1+1Wnkt jf5VKLAZfQjU6FlYCtdD8aTpfbwCtTPGWxbz/xPT88KF/XC/MSUToQh2thOqYdFz58qi 08xX9Vwi3+UHSqbeu9/MeIARZp3fjOjAggTDyxiCfGr5Sx8i9Y0YRhydJ9DJMD8YrpMk wIe242ZlMTWirBHHw6JJ0eHeRumf0Gx2h7RowJZPoq/+xEJ2MAfPC3mrLW9XbZzXuf2z rubjPK3ZuzGLQoltrm3MtFXSVbDq9niroWa3RyFRq5NJjcYdh+jLFHIDX03a/Mj/QFdQ eRcQ== X-Gm-Message-State: AOJu0YzN46Uj5NgeTNLdF1bm2wLx9pbQm/L1eMK9PO06EwqCLsFstvpd U1tFgOla1k3ekTxvR2PYM+lLz51IKyOdQqLvRLu6uM9kQSOyp6xszTb/7+URB847CB/+dXr/Uwq dAaBvrVs5iCAS3aXIUXLs5uQ4P8WSBA== X-Google-Smtp-Source: AGHT+IHLZ6OSlXusSYMs39bHF39BClJgkJApuJwMvtTjLUpl7fyXnQ2NgyjrNQ5JovcZFqjFilCAxYY+1BApaK2aQmk= X-Received: by 2002:a5d:62d0:0:b0:354:db35:63ab with SMTP id ffacd0b85a97d-35efed66c04mr3292453f8f.39.1717836609191; Sat, 08 Jun 2024 01:50:09 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <0a6a61cd-f203-4dea-a7f8-97e6b885c52d@app.fastmail.com> <734bb8e8-2fdf-4e50-9039-e53c99ee4930@app.fastmail.com> <89b695d7-661f-4c1b-ac4c-4480ad158e83@app.fastmail.com> <6d644f0f-cbeb-484c-b267-bf1d97e6d27a@app.fastmail.com> <10AAAA51-9538-4F97-83D1-91F154C745F7@gmail.com> <0b6d7308-3c32-477c-8bf2-e8e0880cbb05@app.fastmail.com> In-Reply-To: <0b6d7308-3c32-477c-8bf2-e8e0880cbb05@app.fastmail.com> Date: Sat, 8 Jun 2024 11:49:33 +0300 Message-ID: Subject: Re: [PHP-DEV] [RFC] Asymmetric Visibility, v2 To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000df88ae061a5d00a5" From: arvids.godjuks@gmail.com (Arvids Godjuks) --000000000000df88ae061a5d00a5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 7 Jun 2024 at 17:30, Larry Garfield wrote: > On Wed, Jun 5, 2024, at 7:55 PM, Arvids Godjuks wrote: > > On Wed, 5 Jun 2024 at 19:59, Claude Pache > wrote: > > *snip* > > Hello everyone, > > I've been seeing readonly bashed/blamed/being roadblock, etc, etc as in > > the implementation ended up being sloppy and blocking other things or > > making things hard... > > While I know BC is king and stuff, why not just say "yes, this was > > designed badly and we will redo it" and just do it? While there's not > > yet an absolute boatload of that code out there when it would be > > absolutely massive BC break? Don't repeat the mistakes of the old days > > :D > > Well, readonly has been out for 3 years. There is an absolute boatload o= f > code out there that we do not want to break. :-) > > > Cause the impression I'm getting any significant RFC now has to work > > around the readonly's sloppy implementation and there's a bigger and > > bigger section on that with each next RFC when there's more and more > > advanced features for the OOP part of things. > > It's not a sloppy implementation per se. (I can't actually speak to the > implementation myself.) It's the design of an implicit private(set) that > works differently from any other private variable. The issue with "thou > shalt not touch it outside of the constructor" isn't a language bug, it's= a > static-analyzer bug that those projects refuse to fix. Not something we > can really do much about here. Uninitialized wasn't introduced by readon= ly > but by property types in 7.4; readonly just inherited it. For hooks, the > issue is that readonly needs a value to check to see if it's uninitialize= d, > and with hooks, you don't always have that. > > I think at this point, the change discussed above (making it implicit > protected(set)) is the best we could do. In an ideal world, we would hav= e > never added readonly in the first place and just added aviz back in 8.1, > which would cover nearly all the same use cases with fewer edge cases and > oddities. Sadly, the world is not ideal. > > --Larry Garfield > It does depend on what the fix is - if we are talking removing readonly keyword - that's a yikes and if we go that route, it needs to have an official rector migration thing and it better be officially endorsed and provided :) If we are talking about tweaking how readonly works in some cases - while not great, I hold the opinion that it's better to fix it now than 20 years down the line. I do have to say that I do not see a "=3D=3D" between aviz and readonly. Wh= ile I can see how you can implement readonly with aviz, the boilerplate seems not worth it, especially for bigger classes/structures where you just designate the whole class with one "readonly class MyClass { ... }". And constructor promotion with "private readonly Class $class" with DI is basically all my services now - it's convenient and short and I really do not need any more than that from the readonly :) Maybe simplifying readonly is the answer and use aviz for more complicated cases? --=20 Arv=C4=ABds Godjuks +371 26 851 664 arvids.godjuks@gmail.com Telegram: @psihius https://t.me/psihius --000000000000df88ae061a5d00a5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, 7 Jun 2024 at 17:30, Larry Garfie= ld <larry@garfieldtech.com= > wrote:
On Wed, Jun 5, 2024, at 7:55 PM, Arvids Godjuks wrot= e:
> On Wed, 5 Jun 2024 at 19:59, Claude Pache <claude.pache@gmail.com> wrote: > *snip*
> Hello everyone,
> I've been seeing readonly bashed/blamed/being roadblock, etc, etc = as in
> the implementation ended up being sloppy and blocking other things or =
> making things hard...
> While I know BC is king and stuff, why not just say "yes, this wa= s
> designed badly and we will redo it" and just do it? While there&#= 39;s not
> yet an absolute boatload of that code out there when it would be
> absolutely massive BC break? Don't repeat the mistakes of the old = days
> :D

Well, readonly has been out for 3 years.=C2=A0 There is an absolute boatloa= d of code out there that we do not want to break. :-)

> Cause the impression I'm getting any significant RFC now has to wo= rk
> around the readonly's sloppy implementation and there's a bigg= er and
> bigger section on that with each next RFC when there's more and mo= re
> advanced features for the OOP part of things.

It's not a sloppy implementation per se.=C2=A0 (I can't actually sp= eak to the implementation myself.)=C2=A0 It's the design of an implicit= private(set) that works differently from any other private variable.=C2=A0= The issue with "thou shalt not touch it outside of the constructor&qu= ot; isn't a language bug, it's a static-analyzer bug that those pro= jects refuse to fix.=C2=A0 Not something we can really do much about here.= =C2=A0 Uninitialized wasn't introduced by readonly but by property type= s in 7.4; readonly just inherited it.=C2=A0 For hooks, the issue is that re= adonly needs a value to check to see if it's uninitialized, and with ho= oks, you don't always have that.

I think at this point, the change discussed above (making it implicit prote= cted(set)) is the best we could do.=C2=A0 In an ideal world, we would have = never added readonly in the first place and just added aviz back in 8.1, wh= ich would cover nearly all the same use cases with fewer edge cases and odd= ities.=C2=A0 Sadly, the world is not ideal.

--Larry Garfield

It does depend on what the fix is= - if we are talking removing readonly keyword - that's a yikes and if = we go that route, it needs to have an official rector migration thing and i= t better be officially endorsed and provided :)
If we are talking= about tweaking how readonly works in some cases - while not great, I hold = the opinion that it's better to fix it now than 20 years down the line.=

I do have to say that I do not see a=C2=A0"= =3D=3D" between aviz and readonly. While I can see how you can impleme= nt readonly with aviz, the boilerplate seems not worth it, especially for b= igger classes/structures where you just designate the whole class with one = "readonly class MyClass { ... }". And constructor promotion with = "private readonly Class $class" with DI is basically all my servi= ces now - it's convenient and short and I really do not need any more t= han that from the readonly :) Maybe simplifying readonly is the answer and = use aviz for more complicated cases?
--

Arv=C4=ABds Godjuks
+371 26 851 664
Telegram: @psihius=C2=A0https://t.me/psihius
--000000000000df88ae061a5d00a5--