Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array

2024-10-21 Thread mickmackusa
On Mon, Oct 21, 2024 at 3:24 PM Larry Garfield wrote: > I am confused by this statement. How is "adding more functions that do > exactly what they say on the tin and act in a predictable fashion" bad? > It's not like we're running out of space for functions. Small, > purpose-built, highly-predi

Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array

2024-10-21 Thread Morgan
On 2024-10-21 06:42, Gina P. Banyard wrote: Hello internals, I would like to propose a short RFC to make the return value of the sort() and similar functions more useful: https://wiki.php.net/rfc/array-sort-return-array I intend for the discussion to last 2 weeks and then open the vote. Best

Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array

2024-10-21 Thread Ilija Tovilo
Hi Gina On Mon, Oct 21, 2024 at 3:21 PM Gina P. Banyard wrote: > > On Sunday, 20 October 2024 at 18:42, Gina P. Banyard > wrote: > > > https://wiki.php.net/rfc/array-sort-return-array > > For an example, I'm going to pull out my solution to day 1 of the 2022 > advents of code: > > https://gith

Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array

2024-10-21 Thread mickmackusa
On Mon, 21 Oct 2024, 18:09 Morgan, wrote: > You can’t use: > $sorted_datasets = array_map(sort(...), $datasets); > You want > $sorted_datasets = $datasets; > array_walk($sorted_datasets, sort(...)); > A warning: no one should ever use array_walk($sorted_datasets, sort(...

Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array

2024-10-21 Thread Gina P. Banyard
On Sunday, 20 October 2024 at 18:42, Gina P. Banyard wrote: > Hello internals, > > I would like to propose a short RFC to make the return value of the sort() > and similar functions more useful: > https://wiki.php.net/rfc/array-sort-return-array I am going to respond out of threads. This RF

Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array

2024-10-21 Thread Gina P. Banyard
On Monday, 21 October 2024 at 14:29, Ilija Tovilo wrote: > Hi Gina > > On Mon, Oct 21, 2024 at 3:21 PM Gina P. Banyard intern...@gpb.moe wrote: > > > On Sunday, 20 October 2024 at 18:42, Gina P. Banyard intern...@gpb.moe > > wrote: > > > > > https://wiki.php.net/rfc/array-sort-return-array >

Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array

2024-10-21 Thread Valentin Udaltsov
On Mon, 21 October 2024 г. at 18:13, Gina P. Banyard wrote: > > On Monday, 21 October 2024 at 14:29, Ilija Tovilo > wrote: > > > Hi Gina > > > > On Mon, Oct 21, 2024 at 3:21 PM Gina P. Banyard intern...@gpb.moe wrote: > > > > > On Sunday, 20 October 2024 at 18:42, Gina P. Banyard intern...@gpb.m

Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array

2024-10-21 Thread Morgan
On 2024-10-22 00:17, mickmackusa wrote: On Mon, 21 Oct 2024, 18:09 Morgan, > wrote: You can’t use:         $sorted_datasets = array_map(sort(...), $datasets); You want         $sorted_datasets = $datasets;         array_walk($sorted_datasets, s

Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array

2024-10-21 Thread Rowan Tommins [IMSoP]
On 21/10/2024 14:20, Gina P. Banyard wrote: This RFC does*NOT* change the by-ref parameter passing*NOR* the in-place sorting of these functions. I don't see why people are thinking this would be changed, as I only ever talk about the return value. But I added a sentence in the Unaffected PHP Fu

Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array

2024-10-21 Thread mickmackusa
On Tue, 22 Oct 2024, 02:30 Valentin Udaltsov, wrote: > > What if instead of this proposal we reimplement all of the array > functions in a different namespace and fix a lot of other problems and > inconsistencies? > > Array\map(iterable $iterable, callable $mapper): array > Array\sort(iterable $i

Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array

2024-10-21 Thread Bilge
On 21/10/2024 21:41, mickmackusa wrote: On Tue, 22 Oct 2024, 02:30 Valentin Udaltsov, wrote: What if instead of this proposal we reimplement all of the array functions in a different namespace and fix a lot of other problems and inconsistencies? Array\map(iterable $iterable,