Re: [RFC] [DISCUSSION] Immutable/final/readonly properties
| From: | Larry Garfield | Date: | Sun, 15 Mar 2020 18:43:29 +0000 |
| Subject: | Re: [RFC] [DISCUSSION] Immutable/final/readonly properties | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-109036@lists.php.net to get a copy of this message | ||
On Sun, Mar 15, 2020, at 8:48 AM, Marco Pivetta wrote:
> Hey Máté,
>
> On Sun, Mar 15, 2020, 14:04 Máté Kocsis <kocsismate90@gmail.com> wrote:
>
> > Hi Marco,
> >
> > Yes, it still allows default values.
> >
> > The reason why I'm reluctant to disallow them is that this restriction
> > would feel a bit ad-hoc for me. I mean, I wouldn't like to add another
> > special rule for "write-once" properties, unless there is a strong
> > argument for it. Besides, as far as I know there is no precedents of
> > disallowing default values of similar properties in other languages,
> > so I feel that the feature would stay the most intuitive as it is now.
> >
>
> I think what will happen is that people will start requesting for read-only
> properties with default values to be over-writable-once (a mess): better to
> remove them from the equation completely, no?
My concern is that if a readonly property can have a default value which is not overwriteable, then
it's conceptually isomorphic to a class constant. That will lead to ample questions and
debates about whether you should use a class constant or a read-only property, or when you should
use one or the other. I foresee numerous bikeshed debates about that, which will only lead to
thousands of hours of lost time debating something that shouldn't exist.
Avoiding that confusion will save the industry millions of dollars.
--Larry Garfield