Re: [RFC] [Discussion] Clone with
| From: | Larry Garfield | Date: | Thu, 20 Apr 2023 14:17:45 +0000 |
| Subject: | Re: [RFC] [Discussion] Clone with | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120080@lists.php.net to get a copy of this message | ||
On Thu, Apr 20, 2023, at 7:00 AM, Rowan Tommins wrote:
> Rather than making everything use an array or array-like syntax, I
> would probably go the other way and scrap the special syntax for
> dynamic names, making the whole thing look like a function call, with
> support for array unpacking:
>
> $point = clone $point with (x: $x, y: $y, z: $z);
> $point = clone $point with (...['x' => $x, 'y' => $y, 'z'
> => $z]);
I agree here, for all the reasons Rowan indicated. We already have a perfectly good syntax and
semantics for named arguments that supports splat. Using that here would handle all the use cases
we care about, including dynamic names, without any additional syntax.
Let's not shoe-horn arrays in here where they're not needed. Making arrays themselves
fancier/more compact with an alternate syntax is worth discussing, but that should be a separate
RFC.
--Larry Garfield