Re: [RFC] Partial function application

From: Date: Tue, 11 May 2021 16:57:45 +0000
Subject: Re: [RFC] Partial function application
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-114412@lists.php.net to get a copy of this message
> On Sun, Apr 25, 2021, at 2:25 PM, Larry Garfield wrote:
> > Greetings, Internalians!
> >
> > I would like to offer for your consideration another RFC, specifically
> > syntax for partial function application.
> >
> > https://wiki.php.net/rfc/partial_function_application
> >
> > It includes an implementation by Joe Watkins that is already about 95%
> > complete.  (There's some edge cases he's still sorting out, but all of
> > the typical cases should work already.)  Most of the design work comes
> > from Levi Morrison and Paul Crovella.  I helped out with the tests, a
> > few edge bits, and general instigator/nudge. :-)
> >
> > Discuss.
>
> It looks like the conversation has died down, and it's been two weeks, so
> pending any other notable feedback I'll open a vote on this RFC on Thursday
> or Friday.
>
> --Larry Garfield
>

LGTM, thanks for the RFC!

What about visibility? I suppose this works even outside the object scope?
should this be mentionned?
$foo = $this->somePrivateMethod(1, ?)

Would it make sense to support a way to use a placeholder for "all
remaining args"?
Eg:
$foo = some_func(1, ...?)

Combined with my previous comment, this could replace
Closure::fromCallable() by a language construct, which is something that we
already discussed in another thread (we talked about some ::function
special suffix instead):
$foo = $this->somePrivateMethod(...?)

In this last form, we might make this result in Closure::fromCallable()
exactly. Aka no increase of the depth of the stack trace.

BTW, ideally, partial functions should not increase the depth of the
stacktrace at all. Do they?

Nicolas


Thread (68 messages)

« previous php.internals (#114412) next »