Re: Pipe Operator v2

From: Date: Thu, 21 Jul 2016 02:35:05 +0000
Subject: Re: Pipe Operator v2
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-94601@lists.php.net to get a copy of this message
Hi Thomas, On Thu, Jul 21, 2016 at 9:05 AM, Thomas Bley <mails@thomasbley.de> wrote: > to me this code is perfectly readable and static code analysis is only complaining about > missing semicolons at the end of the lines and short variable names: > > $x = loadConfig(); > $x = buildDic($x); > $x = getApp($x) > $x = getRouter($x) > $x = getDispatcher($x, $request) > $x = dispatchBusinessLogic($x, $request, new Response()) > $x = renderResponse($x) > $x = buildPsr7Response($x) > $response =emit($x); > I agree the example code is readable, but it makes me feel the language is a little obsolete. Many coding standards, if not most, require to have meaningful variable names even for temp variables. $response = loadConfig() |> buildDic($$) |> getApp($$) |> getRouter($$) |> getDispatcher($$, $request) |> dispatchBusinessLogic($$, $request, new Response()) |> renderResponse($$) |> buildPsr7Response($$) |> emit($$); Nice, clean, readable and explicit. i.e. Don't have convert $x is return value from previous call in programmer's head. > I'm not sure if there is a ORM or database library out there which constructs SQL queries > with non-oop calls, maybe you can give a real-world example. F# supports function pipelining by |> operator https://msdn.microsoft.com/en-us/visualfsharpdocs/conceptual/functions-%5bfsharp%5d#function-composition-and-pipelining It differs a little, but real world function pipelining examples could be found in F#/OCaml codes. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#94601) next »