Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123488 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 DAF681A009C for ; Mon, 3 Jun 2024 07:54:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717401329; bh=b6Sschq1i68JP9CPSOOIEf8wqMJqhxrFTiyg7L6CMUk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SYJJ+aoEgaTV9BM4j6lb456IBfmyCYlC85mwIf5bo/bRFDO8lkf1raVBx1Exsx+OS p5jWeKcCpm+7J9sS1dCVYiCaTexCTNWPUuJz7W9eNag/N84MGD1iENtSQDCfcx5Wcj XUnjNOzraGNocXQZSK8cTBtBE5TEthKxNXxtWbZnvrJiDL5wbhtU8ToOpf5Sgw31B+ ZbQQT/UmCsMxl8dqbqxY/DI40/ceerByZCIJ8CWTT0lfmKkUzHXQhqM6FyGWLv4CyY 07BM5m4K/BQvuL4e3YwvWuXJa0Mx7dvKF2qFC5sWyzBZ7nQc/ZCbwAiPL+589+eQ7x nMRKmTUFTievQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 993C6180050 for ; Mon, 3 Jun 2024 07:55:28 +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-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (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 ; Mon, 3 Jun 2024 07:55:28 +0000 (UTC) Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-dfa59c35e44so4068226276.3 for ; Mon, 03 Jun 2024 00:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717401264; x=1718006064; 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=zpSRrnl5IpcCuTbpqcRqGKSOrdmiavtF/KA8257Q6uI=; b=CPyfPYMXVQy3Ke2ttGVff2M4wRheER7RR/ulgidAu8NvFLIrp08mwMXvcuOG29fRTF tyX6DuUAx1GJ+No8VhYav5XSTpP8T43fsLOfbD2V4oryiNfKfl8Ki/Ts6KgRIPKMYDQQ uxrPr86Fb4VCh4Lmz4ZISlgu0r8m7yt5UcWh96f3EG8b+LwE9YWWb6ES7qrm+vahPP+H g9r3mVgrLCi/FyQa+XJlOwpGdBHq8ztoeF+h93n7bur3Tib2gh9HoJSD2b5I1N1Q1qIj SJgAidv8cXu2ujyBZcpbYlaKYhLA9ekikQ0kCF7fHENP9KM12VWtIPIYxAGawNdocqKS Pa8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717401264; x=1718006064; 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=zpSRrnl5IpcCuTbpqcRqGKSOrdmiavtF/KA8257Q6uI=; b=k2BoYUYNSmEeOUl9yJBkDolOj84aQbM+awqUKE2yspVc/MHccEz0XLc5rdhNf0q1Uz 8DSlgTpvlA2CRAV2d/tSiwi8Z0VsvOnYOYq3Fm0ecNchc5OXn7jGrMtr/QcfQiEzOeYu wYDv7JvWxjBrfH+uFxMaT+Xa0f483NYmsR04RRdlIt5coQbntQLjvuvHORQw249G9uvV v+lD+g+7VxBn5Mw2LI6pJDAkpsLmYe6hrPjAxf8GtEL4aeFNYBjidVS3IvSPtegOI3vM FGI2stSE2sm458S30H76Nn7Op99qMn47VFqC5L05ZR7s+c1rVDTrfUatVaLcyCffcPFp 75Bw== X-Gm-Message-State: AOJu0YzW6iNasTsQwRrQu73i8t45yAJZtTVgfZ2PnNK/cfMmcHMgITpp 6TnmkMnEsrynEg88oWguFf6nbhB2QDl9OKpYWNchgK+dHNtA9URAJcGL+gyHBBWo5BvTkI59UVh Iaee/eBTGkps0OHNhkMZb+Nyu+Xy7CaIAQDA= X-Google-Smtp-Source: AGHT+IGxV0WdyLItWl1WWXkWxp3aSsIJu1cPTyrVlpGNhErN+QCCgJk0GQzPUH3Tr2n3lbUBpU4ItQJ/ki5Dhm/mM1I= X-Received: by 2002:a25:a2cc:0:b0:df4:dd49:7ae7 with SMTP id 3f1490d57ef6-dfa73c3490dmr7622580276.24.1717401264136; Mon, 03 Jun 2024 00:54:24 -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> In-Reply-To: <734bb8e8-2fdf-4e50-9039-e53c99ee4930@app.fastmail.com> Date: Mon, 3 Jun 2024 10:54:07 +0300 Message-ID: Subject: Re: [PHP-DEV] [RFC] Asymmetric Visibility, v2 To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000004928e90619f7a472" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --0000000000004928e90619f7a472 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, May 31, 2024 at 7:13=E2=80=AFPM Larry Garfield wrote: > > So we feel the best way forward is to make the following changes: > > * private(set) implicitly means "final". (You can declare it explicitly > if you want, but it isn't necessary.) > * Make readonly incompatible with aviz again. > > Thoughts? > I think making properties `final` when using `private(set)` is a good solution to this. I don't think `readonly` needs to be incompatible with aviz. We can have `readonly` act as `private(set`) but not `final` by default. But you can define it as `private(set) readonly`, and in this case it will be `final`, practically the same as `final readonly`. It would go like this: - private(set) -> final, private(set) - final private(set) -> final, private(set) - readonly -> write-once, private(set) - final readonly -> final, write-once, private(set) - private(set) readonly -> final, write-once, private(set) - protected(set) readonly -> write-once, protected(set) - public(set) readonly -> write-once, public(set) > > Also, Alexandru noted earlier that final properties don't seem to be > supported in constructor promotion. That's an oversight from the hooks > implementation, not a design choice, so Ilija will just fix that as part = of > the hooks PR before it gets fully merged. > Maybe we need to have some discussion/considerations about allowing new modifiers on constructor promoted properties parameters. Right now there is no `final` modifier for parameters, but this means we might not be able to allow them in the future. In other languages (Java), it makes the parameter variable a constant (not reassignable). So this decision might have implications so that when we decide to make variables or parameters not reassignable, we will not be able to use "final" as a keyword. Not saying there is a problem, just that we need to be aware of it, as probably `final` is not a very good choice, and `const` or `readonly` are probably better options. Alex --0000000000004928e90619f7a472 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Fri, May 31, 2024 at 7:13=E2=80=AFPM L= arry Garfield <larry@garfieldt= ech.com> wrote:

So we feel the best way forward is to make the following changes:

* private(set) implicitly means "final".=C2=A0 (You can declare i= t explicitly if you want, but it isn't necessary.)
* Make readonly incompatible with aviz again.

Thoughts?

I think making properties `fi= nal` when using `private(set)` is a good solution to this.

I don't think `readonly` needs to be incompatible with aviz. W= e can have `readonly` act as `private(set`) but not `final` by default.
But you can define it as `private(set) readonly`, and in this case i= t will be `final`, practically the same as `final readonly`.
It w= ould go like this:
- private(set) -> final, private(set)
- final private(set) -> final, private(set)
- rea= donly ->=C2=A0write-once, private(set)
- final readonly -> = final, write-once, private(set)
- private(set) readonly -> fin= al, write-once, private(set)
- protected(set) readonly -> = write-once, protected(set)
- public(set) readonly -> write= -once, public(set)
=C2=A0

Also, Alexandru noted earlier that final properties don't seem to be su= pported in constructor promotion.=C2=A0 That's an oversight from the ho= oks implementation, not a design choice, so Ilija will just fix that as par= t of the hooks PR before it gets fully merged.

Maybe we need to have some discussion/considerations about allowing= new modifiers on constructor promoted properties parameters.
Right now = there is no `final` modifier for parameters, but this means we might not be= able to allow=C2=A0them in the future.
In other languages (J= ava), it makes the parameter variable a constant (not reassignable).
<= div>
So this decision might have implications so that when we= decide to make variables or parameters not reassignable, we will not be ab= le to use "final" as a keyword.
Not saying there is a p= roblem, just that we need to be aware of it, as probably `final` is not a v= ery good choice, and `const` or `readonly` are probably better options.

Alex

--0000000000004928e90619f7a472--