Re: [RFC] [Discussion] Clone with
| From: | Derick Rethans | Date: | Fri, 05 May 2023 15:31:28 +0000 |
| Subject: | Re: [RFC] [Discussion] Clone with | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120193@lists.php.net to get a copy of this message | ||
On Mon, 17 Apr 2023, Máté Kocsis wrote:
> Hi Everyone,
>
> Quite some time after mentioning the "clone with" construct the first time
> (at the end of the
>
> https://wiki.php.net/rfc/write_once_properties#run-time_behaviour
> section),
> finally I managed to create a working implementation for this feature which
> would make it possible to properly modify readonly properties
> while simplifying how we write "wither" methods:
> https://wiki.php.net/rfc/clone_with
| So far, all “clone with” examples introduced in the current RFC used
| fixed property names which were referenced as identifiers followed by
| a colon (:), while the values to be assigned were expressions.
|
| …
|
| both side of the assignment is an expression, separated by =>
I don't think there should be two syntaxes here. Either allow
expressions on the left side of the ':' or always use '=>' and require a
string on
the LHS. The example already allows for using a string on the LHS in
{"foo" => 1}, so I think that the most useful choice. I don't think in
{PROPERTY_NAME => 1} , the LHS should be interpreted as the literal
value PROPERTY_NAME, but only the value of that constant.
cheers,
Derick