On Tue, 18 Apr 2023 at 22:01, Bob Magic <b...@majdak.net> wrote: > > > [1] In fact if the right hand side of with may be an expression that > > evaluates to an array, folks wouldn't need to learn new syntax at all: > > > > $newProperties = [ "foo" => "bar" ]; > > clone $object with $newProperties; > > > > and > > > > clone $object with [ "foo" => "bar" ]; > > in my opinion this is sick, as in awesome. the {} version makes no sense to > me unless the language gains $var = {} ; to skip $var = (object)[];
I think the {...} is meant to be simply an "argument list", not a value. But yes having an array here would add some flexibility. It would also give us argument unpacking for free. I wonder what this means for performance. Will the expression always be evaluated as an array first, and then applied, or can php do a "shortcut" where it internally treats it as an argument list, even though the syntax implies array? The different will be small, but it could become relevant if called many times over. -- Andreas -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php