Re: [RFC] Partial function application

From: Date: Sun, 25 Apr 2021 21:30:57 +0000
Subject: Re: [RFC] Partial function application
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-114166@lists.php.net to get a copy of this message
2021-04-25 21:07 GMT, Max Semenik <maxsem.wiki@gmail.com>: > On Sun, Apr 25, 2021 at 10:26 PM Larry Garfield <larry@garfieldtech.com> > wrote: > >> https://wiki.php.net/rfc/partial_function_application > > > Amazing, I've wanted this for so long! Have you considered extending this > syntax to OOP, e.g. $obj->method(?) or SomeClass::staticMethod(?)? > > On Sun, Apr 25, 2021 at 10:51 PM Olle Härstedt <olleharstedt@gmail.com> > wrote: > >> Nice. :) Are there any other motivating use-cases besides pipe >> operator (that are relevant for web dev)? > > > One reason I'm personally excited about this proposal is that it would > allow static analysis in more cases, e.g. > > $param = 'fooBar'; // What's this string? A user name? Elon Musk's favorite > color? Text of US Constitution? > > somefunc($param); > > function somefunc($cb) { > $cb(123, 'meh'); // What parameter types does this accept? > } > > Allowing syntax like $param = fooBar(?, ?); would indicate clearly what > this variable receives. Analysis tools would then be able to check if such > a function exists and whether it would receive parameters of expected > types. Like an alternative to value objects (class Email ... )? Not sure I understand how, sorry. Olle

« previous php.internals (#114166) next »