Hi Thomas,

On Thu, Jul 21, 2016 at 9:05 AM, Thomas Bley <ma...@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
yohg...@ohgaki.net

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to