On Thu, Mar 16, 2023 at 10:14 AM Rowan Tommins <rowan.coll...@gmail.com> wrote:
>
> On 15/03/2023 21:12, Dan Ackroyd wrote:
> > Would it be desirable to split those two things into two separate
> > RFCs, by having the first RFC not have native syntax support, but
> > instead another static method on Closure? e.g. something like:
> >
> > Closure::partial($callable, array $position_params, array
> > $named_params): Closure {}
>
>
> Hm... now we have the first-class callable syntax, making it an instance
> method on Closure would allow this:
>
> $mapFoo = array_map(...)->partial([$foo]);
> $filterFoo = array_filter(...)->partial([1 => $foo]);
>
> Which could copy over the full signature, so be equivalent to this:
>
> $mapFoo = static fn(array ...$arrays): array => array_map($foo, ...$arrays);
> $filterFoo = static fn(array $array, int $mode = 0): array =>
> array_filter($array, $foo, $mode);
>
> While being a similar length to a much less rich version:
>
> $mapFoo = fn($array) => array_map($foo, $array);
> $filterFoo = fn($array) => array_filter($array, $foo);
>
>
> Regards,
>
> --
> Rowan Tommins
> [IMSoP]
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>

Rowan, that is actually fairly beautiful.

May not even need the second RFC...

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to