Re: [RFC] Readonly properties
| From: | Mike Schinkel | Date: | Thu, 10 Jun 2021 04:08:02 +0000 |
| Subject: | Re: [RFC] Readonly properties | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-114804@lists.php.net to get a copy of this message | ||
Hi Larry,
Thanks for the response.
> On Jun 9, 2021, at 12:51 PM, Larry Garfield <larry@garfieldtech.com> wrote:
>
> Pierre and Mike:
>
> "Asymmetric visibility" as we keep referring to it would mean the "implicit
> accessors only" version of this:
> https://wiki.php.net/rfc/property_accessors
>
> That is, it would let you define public/private/protected for get and set operations on a
> property separately from each other.
>
> There are three key differences between readonly and asymmetric visibility as described there:
>
> * Asymmetric visibility would allow a property to be reassigned multiple times from within a
> class, readonly would allow writing to it only once when it's uninitialized. Whether one of
> those is too-tight or too-loose is a matter of opinion and context.
When I read your statement I first thought you were wrong, but then I re-read Nikitia's RFC[1]
and realized that RFC stated the properties of an object assigned to a readonly property *could* be
updated, but *not* the readonly property itself.
I wonder if I was the only one who read that mistakenly?
Anyway, have either you or Nikita considered making a distinction between 'public
readonly' and 'private readonly' such that one could disallow any changes after
initialization and the other could allow changes but only within the class?
-Mike
[1] https://wiki.php.net/rfc/readonly_properties_v2#proposal