Re: [RFC] Readonly Properties
| From: | Andrea Faulds | Date: | Fri, 24 Oct 2014 12:03:39 +0000 |
| Subject: | Re: [RFC] Readonly Properties | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78305@lists.php.net to get a copy of this message | ||
> On 24 Oct 2014, at 12:12, Andrey Andreev <narf@devilix.net> wrote:
>
> Pierre, I rarely disagree with you, but this is one such case.
>
> It is true that we can look at this as a partial solution to a bigger
> problem, or as you said - a baby step. However, I see this as the
> perfect solution for a very narrow, yet also a very common problem,
> and I don't see it blocking a more abstract solution in the future.
That’s basically my thoughts on this RFC. I think it’s still quite useful even if it’s not as
useful as it could be without certain other additions.
>
> From a userland POV, it is simple, very effective and there's
> practically no way to achieve the same goal with less amount of code.
>
> In short - it's no panacea to all the limitations that we currently
> have on property management, but it is still *extremely* useful for
> implementing classes that only need to have getters.
It’s also faster!
> On another note, I share Nikita's concern about using the "readonly"
> keyword and I'd love that to be improved, but the best alternative I
> could think of is "readable" and IMO it doesn't have a clearer
> meaning.
Yeah, that’s the problem. It is somewhat unclear, but any other keyword choice is even more
confusing. I discussed this quite a bit in StackOverflow’s PHP chatroom
(http://chat.stackoverflow.com/rooms/11/php) and couldn’t come up with anything better.
Also, as I note in the RFC, we already use readonly in the docs for some classes, and for C#-style
only-set-once read-only properties, we could use final or immutable.
--
Andrea Faulds
http://ajf.me/