Hi Gina

On Sun, Oct 20, 2024 at 7:43 PM Gina P. Banyard <intern...@gpb.moe> wrote:
>
> 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 think this adds two unnecessary sources of confusion:

1. What Rob already mentioned: Users may look at the signature and see
that an array is returned, and assume the argument won't get modified.

2. Is the array returned by value or by reference? I.e.

$a = [...];
$b = &sort($a);
$b[] = 'foo';
// Does $a get modified?

You're mentioning that:

> This behaviour is annoying as it makes writing code in a functional way more 
> cumbersome and tedious.

It would help if there were some examples. In any case, I don't think
by-ref functions are particularly "functional" anyway.

Ilija

Reply via email to