Re: First-class callable partial application
| From: | Rowan Tommins | Date: | Mon, 13 Mar 2023 20:36:59 +0000 |
| Subject: | Re: First-class callable partial application | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119688@lists.php.net to get a copy of this message | ||
On 13 March 2023 18:44:48 GMT, Robert Landers <landers.robert@gmail.com> wrote:
>My approach was more of an iterative one.
>
>1. Get left-right done so that
>
>$x = something($left, $right, ...);
>
>would be allowed, but not
>
>$x = something($left, ..., $right);
>
>This would bring some immediate benefits, as initially proposed.
There are three problems I see with that:
1) The choice of syntax for the first version immediately limits the options for later additions, so
you still need to discuss them. (IIRC, the proposal that went to vote had separate ? and ... tokens,
but a number of different variations were experimented with.)
2) Most of the goals I mentioned above are not about the syntax, and are no easier for left-to-right
- for instance, copying the type information for use in reflection and error messages.
3) Unlike purely or primarily functional languages, PHP's standard library is not at all
designed with parameter orders that lend themselves to left-to-right application. I gave
array_filter as an example, because it's exactly the kind of function people will want to use
PFA for, but wouldn't be able to with left-to-right only.
I don't want to put you off exploring this idea, though, so feel free to take this all with as
many pinches of salt as you want.
Regards,
--
Rowan Tommins
[IMSoP]