Re: [RFC] Pipe Operator
| From: | François Laupretre | Date: | Tue, 17 May 2016 12:15:55 +0000 |
| Subject: | Re: [RFC] Pipe Operator | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-93370@lists.php.net to get a copy of this message | ||
Le 16/05/2016 à 19:53, Sara Golemon a écrit :
I think you're making a false equivalence here. One can see argument ordering consistency as a serious problem without seeing a Heath Robinson version of call chaining as the solution to it. I appreciate that you want to seize onto any opportunity to fix the argument ordering consistency problem, but I don't agree that this is the fix for it.I don't 'seize any opportunity' here. I just think that PHP would do a great step forward if people could write : $res = explode(' ', str_replace($from,$to,trim($input))); as : $input |> trim() |> str_replace($from,$to) |> explode() Eliminating the $$ is a natural complement to your RFC, IMO. It's not something tricky or artificial I would add to an unrelated mechanism.
Right. That's why I propose we start without creating any function alias. We're not supposed to allow writing anything in a pipeline. For every functions, the substituted argument will always be the haystack|subject|source|input argument. That's easy to remember. Regards FrançoisThe question of function aliases is not so serious because we'll need very few. Almost every functions have only one 'natural' argument to substitute as lhs. I'm not sure I understand what you mean with 'but only in certain situations'.If it were so natural, wouldn't the original version of these functions have been made "right" in the first place? I fear that the only thing we'd gain by adding all these aliases is more functions, but without the benefit of any improvement in the argument ordering problem because now, instead of remembering which order the argument is in, users have to remember which alias to call.