Re: A little syntactic sugar on array_* function calls?
| From: | Aleksander Machniak | Date: | Tue, 25 May 2021 11:00:10 +0000 |
| Subject: | Re: A little syntactic sugar on array_* function calls? | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-114582@lists.php.net to get a copy of this message | ||
On 25.05.2021 12:40, Karoly Negyesi wrote:
> $array->map($fn1)->filter($fn2)
>
> 1. It's longer. Much longer.
> 2. It still requires knowing where the array goes. That's legacy which we
> could sidestep with the arrow notation.
> 3. Admittedly, the pipe is much more powerful.
I agree. A unified object oriented interface to arrays (or strings for
that matter) is not a new topic on this list.
I guess you'd have to start with collecting all methods that would need
to be implemented. First stage could be all array_* functions, but I can
imagine others e.g. sorting functions to be included.
> Once again, what I propose here wants to be a simple, cheap to implement,
> narrow quickfix.
I'm afraid it's much more complicated than you think.
> (Although users can add array_foobar($array, $arg1...) for
> $array->foobar($arg1) as they need.)
I wouldn't go that far with this (possible BC break), maybe a future scope.
--
Aleksander Machniak
Kolab Groupware Developer [https://kolab.org]
Roundcube Webmail Developer [https://roundcube.net]
----------------------------------------------------
PGP: 19359DC1 # Blog: https://kolabian.wordpress.com