Re: [RFC] Partial Function Application, take 2
| From: | Joe Watkins | Date: | Fri, 11 Jun 2021 12:41:59 +0000 |
| Subject: | Re: [RFC] Partial Function Application, take 2 | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-114830@lists.php.net to get a copy of this message | ||
There's a couple of typos in the RFC, which Larry will fix when he has time.
There was also a typo in patch, and a fault in patch.
All fixed. pending tests, 3v4l won't update until tomorrow.
Cheers
Joe
On Fri, 11 Jun 2021 at 13:02, Guilliam Xavier <guilliam.xavier@gmail.com>
wrote:
> Sorry, me again :s I have tested the examples from
> https://wiki.php.net/rfc/partial_function_application on
> https://3v4l.org/#focus=rfc.partials and several of them
> currently give an
> error:
>
> - Ex 10: on the line
$c = stuff(?, ?, f: 3.5, ..., p: $point);
> => Fatal error: Named arguments must come after all place holders
> (typo I guess, $c = stuff(?, ?, ..., f: 3.5, p: $point); is OK)
>
> - (Ex 11: no error but a typo: 'hi' vs
> 'foo')
>
> - Ex 16: for the last call (four(..., d: 4, a: 1))(2, 3);
> => Fatal error: Uncaught ArgumentCountError: four(): Argument #2 ($b) not
> passed
> (on the function definition line)
> ((four(..., d: 4, a: 1))(2, 3, 5, 6); idem,
> but (four(..., d: 4, a: 1))(b: 2, c: 3); throws an
> "Unknown named
> parameter $b" Error on the call line)
> (weird)
>
> - func_get_args() and friends: one the last line $f(1, 2);
> (after `$f =
> f(?);`)
> => Fatal error: Uncaught Error: too many arguments for application of f, 2
> given and a maximum of 1 expected
> (can make sense, e.g.
> https://externals.io/message/114532#114554 )
>
> - (Callable reference: no error but a typo: $f vs
> $foo)
>
> - Optimizations: on the line $boo = $baz(4, ...);
> => Fatal error: Uncaught Error: too many arguments and or place holders for
> application of Closure::__invoke, 1 given and a maximum of 0 expected
> ($boo = $baz(?); throws the same error,
> but $boo = $baz(4); throws a "not enough arguments for
> implementation of
> foo, 4 given and exactly 5 expected" Error,
> and $boo = $baz(...); makes the subsequent ’(0
> |øg,ÁDé(KÎ$boo(5); throw a "not enough
> arguments ..." Error)
> (weird, looks like $bar = $foo(2, ...); and/or
> $baz = $bar(3, ...);
> dropped too many params)
>
> Regards,
>
> --
> Guilliam Xavier
>