Hey Larry, hey all On 07.08.22 21:01, Larry Garfield wrote:
On Sun, Aug 7, 2022, at 5:54 AM, Lynn wrote:On Sun, Aug 7, 2022 at 12:34 PM Rowan Tommins <rowan.coll...@gmail.com> wrote:Can you expand on where you think the ambiguity / implicitness is? As I understand it, the RFC is proposing exactly three new combined access levels: - "public private(set)" - "public protected(set)" - "protected private(set)" Although aesthetically it will take a bit of getting used to, it seems to me pretty clear that the first means "mostly public, but private if you want to set it", and so on. The only thing I can think of that could be described as "implicit" is that accessing a property by reference is considered a "set" operation, which I'm not sure how any implementation could avoid.Personally for me it's the syntax. Reading "public private", "public protected", or "protected private" reads really weird `public private(set) static self $property`. In the end it makes sense if you know what it means, otherwise it's probably confusing. I really like this RFC and I feel like this might just be the way to go forward, but I have my doubts about how many more keywords can be realistically added before it becomes a problem.What syntax would avoid having the visibility keyword repeated? if you want "public get, private set" behavior, I don't know how that could be done without having the words "public" and "private" both appear somewhere. Also note, since using private(set) is mutually exclusive with readonly, that the resulting keyword list is about the same length as the existing "public readonly string $foo" that has cropped up frequently with PHP 8.1. So... yes it's another keyword, but it's not more keywords that can exist simultaneously. And moving the keyword to the right (a la C#) wouldn't make it any shorter; if anything it would be even more keystrokes. Very close in size, same in complexity: public readonly string $foo public private(set) string $foo
In my opinion those are actually two different things.One is allowing a variable to be publicly readably and writeable. But it can only be set once. Every subsequent call to setting a new value will fail.
The other is allowing different scopes for reading and writing the variable. The variable can be read publicly but can only be set from within the current class-context. But setting it from the current class context can happen multiple times.
So it should indeed be possible to combine both possibilities: public(get) private(set) readonly string $foo; My 0.02€ Cheers Andreas -- ,,, (o o) +---------------------------------------------------------ooO-(_)-Ooo-+ | Andreas Heigl | | mailto:andr...@heigl.org N 50°22'59.5" E 08°23'58" | | https://andreas.heigl.org | +---------------------------------------------------------------------+ | https://hei.gl/appointmentwithandreas | +---------------------------------------------------------------------+
OpenPGP_0xA8D5437ECE724FE5.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature