Re: [PHP-DEV] Array spread append

2023-04-06 Thread Vorisek, Michael
The goal is fast multi-item array append, which is currently not possible, as `+=` and `array_push` operators does something else and `array_merge` is very slow as the whole array is copied. Currently the fastest approach is to use the foreach equivalent, which requires much more code and two

Re: [PHP-DEV] Array spread append

2023-04-06 Thread Michał Marcin Brzuchalski
czw., 6 kwi 2023, 13:53 użytkownik Vorisek, Michael napisał: > Hi Ilija, > > * Are integer keys preserved? I'm assuming no, as otherwise it would > be the same as `$a + $b`. > > $arr[...] = $arr; > should be the same as > foreach ($arr as $v) { $arr[] = $v; } > I'd argue with that because I

Re: [PHP-DEV] Array spread append

2023-04-06 Thread G. P. B.
On Thu, 6 Apr 2023 at 14:04, mickmackusa wrote: > I think it would be more intuitive to implement an array "appending" > functionality with "concatenating" syntax. The `.=` syntax already exists, > but is forbidden from use on non-strings. If you want to implement this > preexisting syntax as

Re: [PHP-DEV] Array spread append

2023-04-06 Thread mickmackusa
> > > * Are integer keys preserved? I'm assuming no, as otherwise it would > be the same as `$a + $b`. > > $arr[...] = $arr; > should be the same as > foreach ($arr as $v) { $arr[] = $v; } > > all other answers should be answered from this and consistency Since `$arr1[...] = $arr2;` should be

Re: [PHP-DEV] Array spread append

2023-04-06 Thread Vorisek, Michael
Hi Ilija, * Are integer keys preserved? I'm assuming no, as otherwise it would be the same as `$a + $b`. $arr[...] = $arr; should be the same as foreach ($arr as $v) { $arr[] = $v; } all other answers should be answered from this and consistency * What is the return value of the expression

Re: [PHP-DEV] Array spread append

2023-04-06 Thread Ilija Tovilo
Hi Michael > I would like to open a discussion for > https://github.com/php/php-src/issues/10791 . > [https://opengraph.githubassets.com/a23cb565cc8acac6a33ecab5d9ee68a46f046a1ffe215501673156e506695430/php/php-src/issues/10791] > Array spread append ·

Re: [PHP-DEV] Array spread append

2023-04-06 Thread Michał Marcin Brzuchalski
Hi Mick czw., 6 kwi 2023 o 10:00 mickmackusa napisał(a): > Call me sentimental, but are we just trying to choke out the few remaining > reasons to keep array_push() in the language? > > Okay, yeah, sometimes at is a drag that the first parameter has to be > declared in advance and is modified

Re: [PHP-DEV] Array spread append

2023-04-06 Thread mickmackusa
Call me sentimental, but are we just trying to choke out the few remaining reasons to keep array_push() in the language? Okay, yeah, sometimes at is a drag that the first parameter has to be declared in advance and is modified by reference (which means you can't enjoy null coalescing or short