Re: [RFC] Pipe Operator (again)

From: Date: Fri, 07 Feb 2025 19:48:02 +0000
Subject: Re: [RFC] Pipe Operator (again)
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Fri, Feb 7, 2025, at 10:51 AM, Christoph M. Becker wrote:

>> Of particular note, since the last RFC I have concluded that a compose operator is a
>> necessary complement to a pipe operator.  However, it's also going to be notably more work, and
>> the two operators don't actually interact at all at the code level, so since people keep saying
>> "Small RFCs!", here's a small RFC. :-)
>
> Fair enough.  And with the pipe operator, one might live without a
> compose operator, e.g.
>
>   $f1 = fn($x) => 2 * $x;
>   $f2 = fn($x) => $x + 3;
>   // $f3 = $f2 ∘ $f1
>   $f3 = fn($x) => $x |> $f1 |> $f2;
>
> Christoph

The v2 RFC took that position, that compose was easy enough to emulate via pipe.  Indeed, pipe and
compose can both be implemented in terms of each other.  However, since the previous RFC I've
concluded[1] that both are sufficiently useful that we really out to include both of them.  PIpes
are just way easier to implement in practice. :-)

--Larry Garfield

[1] https://peakd.com/hive-168588/@crell/aoc2021-review


Thread (38 messages)

« previous php.internals (#126340) next »