Hi
On 4/20/23 16:17, Larry Garfield wrote:
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.
FWIW I'm not too attached to my array proposal [1]. I would also be fine
with Rowan's proposal of making the "with()" syntactically identical to
a function call, if that's more agreeable.
But please no entirely new syntax with braces as it currently is shown
in the examples in the RFC.
Best regards
Tim Düsterhus
[1] Though I still consider arrays to be more "natural" than named
arguments.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php