Re: [RFC] Partial function application

From: Date: Fri, 14 May 2021 21:48:53 +0000
Subject: Re: [RFC] Partial function application
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-114475@lists.php.net to get a copy of this message

> On May 14, 2021, at 4:18 PM, Mark Randall <marandall@php.net> wrote:
> 
> 
> Passing more arguments than the partial defines would result in an argument count error.
> 

I think it’s reasonable to allow passing more arguments to a partial since user-defined functions
and closures allow this without error.

Whether or not the extra arguments are automatically forwarded to the function wrapped by the
partial is debatable.

Consider function foo(int $x, int $y, int $z) {} with a partial defined as
$partial = foo(?, 42).

If the partial is called as $partial(73, 8), should 8 be forwarded to $z
or should the call error as providing too few arguments? Or perhaps should the partial declaration
should error, as it should have been foo(?, 42, ?) or `foo(?, 42, ...?) so the partial
provided all required arguments to foo.

Cheers,
Aaron Piotrowski


Thread (68 messages)

« previous php.internals (#114475) next »