Re: [RFC] Pipe Operator

From: Date: Sun, 01 May 2016 14:39:21 +0000
Subject: Re: [RFC] Pipe Operator
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-93020@lists.php.net to get a copy of this message
On 30 April 2016 at 07:49, Marco Pivetta <ocramius@gmail.com> wrote: > Here's the pseudo-code for a typical request/response dispatch cycle: Hi Marco, Could you clarify something for me? If I submitted a pull-request to you, with variables named like this: $v = buildRequest(); $v = validate($v); $v = convertToCommand($v); $v = execute($v); $v = convertToViewModel($v); $v = render($v); $v = convertToHttpResponse($v); emit($v); There is no chance that you would accept it. You would (correctly) observe that the variables for the intermediate steps have meaningless names and so the code is hard to reason about. I don't think removing the presence of the intermediate variables and replacing them with $$ improves this situation. What is it that having a special pipe operator that make this acceptable, other than it covers up the lack of names for the intermediate variables, by using a different syntax? Marco wrote: > Relevant: https://youtu.be/UvD1VjRvGIk I could imagine how having inline branches could be a useful thing for functional programming, for various scenarios, including being able to 'inline' error handling, to be nearer the source of errors. However this RFC does not propose that. cheers Dan

« previous php.internals (#93020) next »