[PHP-DEV] Re: Allowing $a = foo($a) to operate in-place (was Re: [PHP-DEV] Array spread append)

2023-04-10 Thread Niels Dossche
Hi On 10/04/2023 22:11, Tim Düsterhus wrote: > Hi > > On 4/10/23 21:50, Niels Dossche wrote: >>> The suggested optimization of "the input is overwritten with the output" >>> would then also allow to avoid introducing reference parameters just for >>> optimization purposes. The sort() family com

[PHP-DEV] Allowing $a = foo($a) to operate in-place (was Re: [PHP-DEV] Array spread append)

2023-04-10 Thread Tim Düsterhus
Hi On 4/10/23 21:50, Niels Dossche wrote: The suggested optimization of "the input is overwritten with the output" would then also allow to avoid introducing reference parameters just for optimization purposes. The sort() family comes to my mind and also the shuffle() function. Randomizer::sh

Re: [PHP-DEV] Array spread append

2023-04-10 Thread Niels Dossche
Hey Tim On 10/04/2023 14:45, Tim Düsterhus wrote: > Hi > > On 4/8/23 22:17, Niels Dossche wrote: >> I think this could be made more generic, and be cleaned up. >> But I don't know if something like this is desired in PHP. > > Yes, please. I believe that “performance” should not influence API des

Re: [PHP-DEV] Array spread append

2023-04-10 Thread Tim Düsterhus
Hi On 4/8/23 22:17, Niels Dossche wrote: I think this could be made more generic, and be cleaned up. But I don't know if something like this is desired in PHP. Yes, please. I believe that “performance” should not influence API design if it can be avoided. Instead the heavy lifting of optimiza

Re: [PHP-DEV] Array spread append

2023-04-09 Thread Hans Krentel via internals
On Saturday 08 April 2023 22:17:14 (+02:00), Niels Dossche wrote: > However, I think it might be worth adding an optimization for the most common $x = array_merge($x, ...) case. If so, then syntax wise I'd throw that suggestion in the ring: $x[] = ... $y ; This would allow to adopt exi

Re: [PHP-DEV] Array spread append

2023-04-08 Thread Niels Dossche
Hi On 4/6/23 00:12, Vorisek, Michael wrote: > Hello, > > 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]

Re: [PHP-DEV] Array spread append

2023-04-07 Thread Bob Magic
> 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 an array concatenation operator, then it is a blan

Re: [PHP-DEV] Array spread append

2023-04-07 Thread Tim Düsterhus
Hi On 4/6/23 00:12, Vorisek, Michael wrote: I would like to open a discussion for https://github.com/php/php-src/issues/10791 . For the discussion phase to actually be open (with regard to the minimal discussion period before a vote on an RFC may be opened), an actual RFC needs to exist.

Re: [PHP-DEV] Array spread append

2023-04-06 Thread Vorisek, Michael
5:01 PM To: Vorisek, Michael Cc: PHP internals Subject: Re: [PHP-DEV] Array spread append czw., 6 kwi 2023, 13:53 użytkownik Vorisek, Michael mailto:voris...@fjfi.cvut.cz>> napisał: Hi Ilija, * Are integer keys preserved? I'm assuming no, as otherwise it would be the same as `$a +

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 thin

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 a

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 con

Re: [PHP-DEV] Array spread append

2023-04-06 Thread Vorisek, Michael
02Cq - `$arr[...] = &$arr` should be compile error Michael From: Ilija Tovilo Sent: Thursday, April 6, 2023 12:18 PM To: internals@lists.php.net Subject: Re: [PHP-DEV] Array spread append Hi Michael > I would like to open a discussion for > https://

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 by

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 tern

Re: [PHP-DEV] Array spread append

2023-04-05 Thread Andreas Hennings
> I have the feeling I'm missing something, but how would this compare to array join Array join does neither append nor replace if a numeric index already exists. But you can do [...$arr0, ...$arr1]. https://3v4l.org/CIinR print json_encode([ [...['a', 'b'], ...['c', 'd']], // [a, b, c, d]

Re: [PHP-DEV] Array spread append

2023-04-05 Thread Juliette Reinders Folmer
On 6-4-2023 0:12, Vorisek, Michael wrote: Hello, 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]

[PHP-DEV] Array spread append

2023-04-05 Thread Vorisek, Michael
Hello, 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 · Issue #10791