Both sides previous revisionPrevious revisionNext revision | Previous revision |
rfc:pipe-operator-v2 [2021/07/04 01:53] – Remove last PFA trace crell | rfc:pipe-operator-v2 [2021/07/20 15:34] (current) – Close vote. crell |
---|
* Date: 2020-04-20 | * Date: 2020-04-20 |
* Author: Larry Garfield <larry@garfieldtech.com> | * Author: Larry Garfield <larry@garfieldtech.com> |
* Status: Under Discussion | * Status: Declined |
* First Published at: http://wiki.php.net/rfc/pipe-operator-v2 | * First Published at: http://wiki.php.net/rfc/pipe-operator-v2 |
| |
===== Additional semantics ===== | ===== Additional semantics ===== |
| |
Functions that accept their first parameter by reference are supported, and will behave exactly as if they were called in the normal "inside out" fashion. However, unless they return a value as well they are not of much use. | Functions that accept their first parameter by reference are allowed, as are functions that return by reference. They will behave semantically the same as if they were passed a variable by reference or returned a variable by reference via a "normal" call. In practice, however, reference variables are of little use in pipes so this is more of a design artifact than design intent. |
| |
When evaluating a pipe, the left-hand side is fully evaluated first, then the right-hand side, then the right-hand side is invoked using the left-hand side. That is, evaluation is strictly left-to-right. | When evaluating a pipe, the left-hand side is fully evaluated first, then the right-hand side, then the right-hand side is invoked using the left-hand side. That is, evaluation is strictly left-to-right. |
* Laravel includes a [[https://github.com/illuminate/pipeline|Illuminate/Pipeline]] package that has an [[https://agoalofalife.medium.com/pipeline-and-php-d9bb0a6370ca|even more cumbersome syntax]]. | * Laravel includes a [[https://github.com/illuminate/pipeline|Illuminate/Pipeline]] package that has an [[https://agoalofalife.medium.com/pipeline-and-php-d9bb0a6370ca|even more cumbersome syntax]]. |
* The [[https://github.com/azjezz/psl|PHP Standard Library]] (PSL) library includes a [[https://github.com/azjezz/psl/blob/1.8.x/src/Psl/Fun/pipe.php|pipe function]], though it is more of a function concatenation operation. | * The [[https://github.com/azjezz/psl|PHP Standard Library]] (PSL) library includes a [[https://github.com/azjezz/psl/blob/1.8.x/src/Psl/Fun/pipe.php|pipe function]], though it is more of a function concatenation operation. |
| * [[https://github.com/sebastiaanluca/php-pipe-operator|Sebastiaan Luca]] has a pipe library that works through abuse of the ''%%__call%%'' method. It only works for named functions, I believe, not for arbitrary callables. |
* Various blogs speak of "the Pipeline Pattern" ([[https://medium.com/@aaronweatherall/the-pipeline-pattern-for-fun-and-profit-9b5f43a98130|for example]]) | * Various blogs speak of "the Pipeline Pattern" ([[https://medium.com/@aaronweatherall/the-pipeline-pattern-for-fun-and-profit-9b5f43a98130|for example]]) |
| |
==== Javascript ==== | ==== Javascript ==== |
| |
A pipeline operator ''|>'' has been [[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Pipeline_operator|proposed for Javascript]]. As of this writing it is still in early stages and no implementations support it, but it may get accepted in the future. The semantics are essentially the same as described here. | A pipeline operator ''|>'' has been [[https://github.com/tc39/proposal-pipeline-operator/wiki|proposed for Javascript]]. As of this writing it is still in early stages and no implementations support it, but it may get accepted in the future. The semantics are essentially the same as described here. |
| |
==== OCaml ==== | ==== OCaml ==== |
| |
Adopt the Pipe Operator yes/no? Requires a 2/3 majority. | Adopt the Pipe Operator yes/no? Requires a 2/3 majority. |
| |
| <doodle title="Pipe Operator" auth="crell" voteType="single" closed="true"> |
| * Yes |
| * No |
| </doodle> |
| |
| |
===== Patches and Tests ===== | ===== Patches and Tests ===== |