Hi, On Tue, Jun 8, 2021 at 12:09 AM Larry Garfield <la...@garfieldtech.com> wrote:
> On Mon, Jun 7, 2021, at 4:00 PM, Eugene Leonovich wrote: > > On Mon, Jun 7, 2021 at 9:03 PM Larry Garfield <la...@garfieldtech.com> > > wrote: > > > > > https://wiki.php.net/rfc/pipe-operator-v2 > > > > > FTR, there are several typos in the "Hello World" examples > (*strto*t*upper, > > htmlent*i*ties*). Also, these examples will not work as written because > > explode() expects two arguments and will fail if you pass only one: > > https://3v4l.org/tLO0s. > > Hm. You're right. It used to, but it's been a very long time since > explode() allowed an empty split, apparently. I updated the example to use > str_split, which is what I'd intended to do in this case. Thanks. > Are you thinking to implode()? Anyway, you forgot to update one `explode(?)` to `str_split(?)`, and also, the first `fn($v) => 'strtoupper'` should be just `'strtoupper'`. About Haskell, rather than (or in addition to) the function composition [not "concatenation"] (.), I would mention the reverse application operator (&): https://hackage.haskell.org/package/base-4.15.0.0/docs/Data-Function.html#v:-38- One thing I note is that even with PFA, some examples still need an arrow function, e.g. the PSR-7 one: ``` ServerRequest::fromGlobals() |> authenticate(?) |> $router->resolveAction(?) |> fn($request) => $request->getAttribute('action')($request) /* ... */; ``` while in Hack you would write it as: ``` ServerRequest::fromGlobals() |> authenticate($$) |> $router->resolveAction($$) |> $$->getAttribute('action')($$) /* ... */; ``` Also, quoting from https://wiki.php.net/rfc/first_class_callable_syntax#partial_function_application : """ Both approaches to the pipe operator have their advantages. The $$ based variant allows using more than plain function calls in each pipeline step (e.g. you could have $$->getName() as a step, something not possible with PFA), and is also trivially free. A PFA-based optimization would entail significant overhead relative to simple function calls, unless special optimization for the pipe operator usage is introduced (which may not be possible, depending on precise semantics). """ Could you (or Nikita) expand a bit on this (esp. the advantages of the PFA approach / disadvantages of Hack's approach)? Regards, -- Guilliam Xavier