2021-06-28 22:12 GMT+02:00, Larry Garfield <la...@garfieldtech.com>: > On Mon, Jun 28, 2021, at 3:04 PM, Rowan Tommins wrote: >> On 28/06/2021 20:25, Olle Härstedt wrote: >> > Usage (ignoring the pesky undefined constant warnings ><): >> >> >> Unfortunately, you can't ignore those warnings; not least because >> they're fatal errors in PHP 8, as they frankly should have been in PHP 3. >> >> You can use our current ugly callable syntax (strings and two-element >> arrays); you can tackle the complexity of unifying functions with >> constants, and methods with properties (as Levi explained in the other >> thread); or you can add a dedicated callable syntax, which the PFA >> proposal gets us with bells on. >> >> Regards, > > I think that's a pretty good summary. There's nothing that pipes or > partials do that you couldn't emulate in user-space today (really, since 5.3 > is you really wanted to). The emulation is just butt-ugly and slower, which > is why most people don't do it except in very specific cases or if they have > a user-space library available that makes it slightly less butt-ugly. > > The purpose of PFA and pipes (and short functions, and auto-capture > closures, and basically everything else I've been talking about all year) is > to make those things prettier and as fast as reasonable, which makes using > those techniques more natural. Once you start down that path, though, > there's really no usable solution before you get down as far as... PFA and > Pipes in their current form. > > --Larry Garfield
The challenge is to write something that's pretty enough to be considered idiomatic. :) The pipe operator in OCaml is defined by one line: let (|>) v f = f v It wasn't always part of core, but eventually it was so common, it got included by default. Same could happen with a pipe() function in PHP, without the pipe operator, or that the function becomes so common, a new keyword is added instead: `pipe`. But it could probably not happen with a Pipe object requiring you to write ->pipe() at every step - it's too much ceremony and boilerplate. By the way, that's alternative 5) New keyword `pipe` to make the warning about constants shut up in a certain scope. Plus some other magic to allow nice chaining. ^^ Olle -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php