On Thu, Jun 10, 2021 at 11:08 AM Mike Schinkel <m...@newclarity.net> wrote: > > Hi Larry, > > Thanks for the response. > > > On Jun 9, 2021, at 12:51 PM, Larry Garfield <la...@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.
That's not related but an assignment by "reference" consequence. I think :) > > 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? Better formulated than I tried :) I would like to have the readonly keyword to make a property readonly outside the class but read/write inside the class, together with visibility it should cover pretty much all cases (parent class included). Init only could be a separate keyword (allows init only, inside the class or outside the class being defined by the property visibility attributes, protected, private or public). I think users, and myself first when I read it, will have a hard time translating "asymmetric...." part of this whole thing (as in, if one has to go to wikipedia to understand what something does instead of what it looks like ;) ). best, -- Pierre @pierrejoye