Re: First-class callable partial application

From: Date: Tue, 14 Mar 2023 09:16:24 +0000
Subject: Re: First-class callable partial application
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-119690@lists.php.net to get a copy of this message
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]

« previous php.internals (#119690) next »