Re: [RFC] Readonly properties
From: Pierre Date: Fri, 04 Jun 2021 15:35:29 +0000 Subject: Re: [RFC] Readonly properties References: 1 2 Groups: php.internals Request: Send a blank email to internals+get-114731@lists.php.net to get a copy of this message
Le 04/06/2021 à 17:34, Pierre a écrit :Le 04/06/2021 à 17:19, Nikita Popov a écrit :Sorry for the noise. -- PierreHi internals, I'd like to open the discussion on readonly properties: https://wiki.php.net/rfc/readonly_properties_v2 This proposal is similar to the https://wiki.php.net/rfc/write_once_properties RFC that has been declined previously. One significant difference is that the new RFC limits the scope of initializing assignments. I think a key mistake of the previous RFC was the confusing "write-once" framing, which is both technically correct and quite irrelevant. Please see the rationale section ( https://wiki.php.net/rfc/readonly_properties_v2#rationale) for how this proposal relates to other RFCs and alternatives. Regards, NikitaHello, I like this RFC, but I have a question: Specifying an explicit default value on readonly properties is also not allowed: Does that mean I wouldn't be allowed to write something such as: <?php class Point {public function __construct(public readonly int $x = 0,public readonly int $y = 0,) {}} $foo = new Point(x: 12); ?> Because the readonly+promoted+named combo is very powerful but if you can't assign defaults it makes it much less interesting. Regards, -- Pierre Please ignore my mail, the answer is just below...
Thread (40 messages)
| « previous | php.internals (#114731) | next » |
|---|