RE: [PHP-DEV] [RFC] Spread Operator in Array Expression v0.2

This is only part of a thread. view whole thread
  105102
April 5, 2019 09:04 me@jhdxr.com (=?utf-8?b?Q0hVIFpoYW93ZWk=?=)
The [original argument unpacking RFC](https://wiki.php.net/rfc/argument_unpacking?rev=1389442371) does allow positional arguments after unpacking, but later it's changed due to some implement issue, see https://github.com/php/php-src/commit/d3b484df8268f7ab31c4ac39734d4b68ce2e6159

I didn't see the same limit exists for arrays, so I didn't include this rule in my RFC. 

Thanks,
CHU Zhaowei

-----Original Message-----
From: Claude Pache pache@gmail.com> 
Sent: Friday, April 5, 2019 4:04 PM
To: Stijn Peeters <ik@stijnpeeters.nl>
Cc: CHU Zhaowei <me@jhdxr.com>; PHP internals <internals@lists.php.net>
Subject: Re: [PHP-DEV] [RFC] Spread Operator in Array Expression v0.2



> Le 5 avr. 2019 à 09:45, Stijn Peeters <ik@stijnpeeters.nl> a écrit : > > Hi, > > If I understand correctly it is possible in this proposal to use normal arguments after using an unpackable argument: > > $arr4 = array(...$arr1, ...$arr2, 111); //valid > > This is something that is not possible when using argument unpacking in function calls: > > $result = someFunction(...$arr1, ...$arr2, 111); //invalid > > While I personally like the more permissive variety in this RFC, I think this could be a confusing inconsistency, and for clarity's sake it would be better to keep both instances of the unpacking syntax as consistent with each other as possible. > > Best, > Stijn > >
That begs the question: why is this invalid for function calls? In fact, I am able to easily hack around the limitation: $result = someFunction(...$arr1, ...$arr2, ...[111]); // valid but the limitation seems just an unnecessary annoyance. —Claude