Re: First-class callable partial application

From: Date: Tue, 14 Mar 2023 10:39:44 +0000
Subject: Re: First-class callable partial application
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-119691@lists.php.net to get a copy of this message
> Am 14.03.2023 um 10:16 schrieb Rowan Tommins <rowan.collins@gmail.com>: > > On 13/03/2023 20:44, Larry Garfield wrote: >> As has been discussed numerous times, all of the most used array functions need to be >> redesigned to work with iterables, and in many cases make more sense. That would be a natural time >> to also revisit parameter order to fit with whatever partial application syntax was in use. > > > It's not just the array functions, though, it's every single function built into PHP, > and an even longer list of userland library and framework functions; and there will always be > competing reasons for preferring one signature over another. What attracts me about features like > PFA is precisely that they let you work in new ways *without* having to rewrite all of that. > > Some more examples of placeholder-first application, from a quick skim through the > documentation: > > $escape = htmlspecialchars(?, ENT_XML1); > $containsAt = str_contains(?, '@'); > $priceFormatter = number_format(?, 2, ',', '.'); > $addSigToFile = file_put_contents(?, $signature, FILE_APPEND); > $takeOwnership = chown(?, get_current_user()); > $encode = json_encode(?, JSON_THROW_ON_ERROR | JSON_PRESERVE_ZERO_FRACTION); > $unserialize = unserialize(?, ['allowed_classes' => false]); > $isLogger = is_subclass_of(?, LoggerInterface::class, false); > > I'm sure I could look through Laravel's documentation, or Symfony's, and find > examples there too. > > Regards, > > -- > Rowan Tommins > [IMSoP] Hey Rowan, do we actually need *positional* partial application, after a ... token? Would it not be enough, to simply forbid positional arguments after a ... and just allow named arguments? These already have well defined position independent semantics. There may be some desire for a single argument placeholder later on, but this can be introduced later, separately. Bob

« previous php.internals (#119691) next »