Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93119 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47440 invoked from network); 9 May 2016 02:05:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 May 2016 02:05:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.43 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.192.43 mail-qg0-f43.google.com Received: from [209.85.192.43] ([209.85.192.43:35054] helo=mail-qg0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AD/95-04420-260FF275 for ; Sun, 08 May 2016 22:05:23 -0400 Received: by mail-qg0-f43.google.com with SMTP id f74so82115789qge.2 for ; Sun, 08 May 2016 19:05:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=SKMYNQz01oBJ/stgewwOL9gQ6E4FX3vvaRRxC+FDu8A=; b=Y/1uv+W4tQjvNX30qwFdAuR0oH162kJ5B8JMaw0dDYU4nd3/CBOLjSrBziyAt7zw0v ybgW1sSdx5VqExB6olgEA2Ktr2um9qkeCY0pzYNi3b0fSuwxfbwmDHryTke8EScdg+SV ciWoRZGogkUOYBy0gnG2kAs2ek6RK0IHOzkOyr4gdBW6CnGZisYv8MHM11F2iUTwROMw gHbkNgDlWPqPki04bsO4NikJYwjaL8TJBJmwH5xoVbR/n0e19zZwR43Q1s42uL6ZNMJI M1OyPYqf4l27BP9/nVQBReiwPmwNoExyvDN1YAbdx7OxJm0paAhnjE7rLMNd2RuWzDh2 Z+/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=SKMYNQz01oBJ/stgewwOL9gQ6E4FX3vvaRRxC+FDu8A=; b=QKCwNgclt3fnL1OxTwsQL30+Ck1xex/IZUyXMrVxCkk56c2pl+XlcUKKmjXaq8Jhi3 0ZsDHA+BJBdGYQIezqqqLzL7gkmXlO0hpk9aFmYARAfaOw7Bo7+8/4+MnvGdt/QnSgPL xdCzhZSXTbbMBak4wdr2tA9CB0yY1uWVPas18SMIk+n6QQIuo/EbJhf9NsKvpCWxG/te ejENd7lWwP7yBqiQn46y/f1LTQ/hXzso0/R74He3Z3ZU7R7+7WrEQzvLz0I+8uIzD46A yry/k8QSTh12MYhwucARzFWxCDem3LKDpidI+rPGpfOOK1O3vZo4+LN31ykl29AGgpg3 Yrlw== X-Gm-Message-State: AOPr4FVh75vQbvzxQk1xpWEsbzSGfQ4PCq9wOE54T9KnGWhaf+9eWyNNeYfBmc+k/j+W0iA+3ENkkVLr8ERLqA== X-Received: by 10.140.150.20 with SMTP id 20mr33873108qhw.98.1462759520368; Sun, 08 May 2016 19:05:20 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.140.27.133 with HTTP; Sun, 8 May 2016 19:04:40 -0700 (PDT) In-Reply-To: References: <4fc01507-3d07-2309-a4e4-4cad7325249b@gmail.com> <39071a01-a42c-0952-b3a8-b4769c79b56b@fleshgrinder.com> <0ac3be89-6fb4-610a-ef89-0928f264f96c@fleshgrinder.com> <71379db5-b7b8-78b3-ada5-eee34e6e22d6@fleshgrinder.com> Date: Mon, 9 May 2016 11:04:40 +0900 X-Google-Sender-Auth: hG39j2rB1rFtzgswX8W8ssxJvQs Message-ID: To: "internals@lists.php.net" Cc: Ryan Pallas , Sara Golemon Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Pipe Operator From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi, I agree they are bad APIs. Framework/library developer should provide better API On Mon, May 9, 2016 at 1:08 AM, Fleshgrinder wrote: > $request = getGlobals() > |> parseRequest($$) > |> buildPsr7Request($$); should be require('some.lib'); $request = getRequest(); /* where getRequest() is function getRequest() { return getGlobals() |> parseRequest($$) |> buildPsr7Request($$); } */ > > $response = loadConfig() > |> buildDic($$) > |> getApp($$) > |> getRouter($$) > |> getDispatcher($$, $request) > |> dispatchBusinessLogic($$, $request, new Response()) > |> renderResponse($$) > |> buildPsr7Response($$) > |> emit($$); should be require('some.lib'); $request = getRequest(); $response = getResponse($request); /* where getResponse() is function getRequest($request) { return loadConfig() |> buildDic($$) |> getApp($$) |> getRouter($$) |> getDispatcher($$, $request) |> dispatchBusinessLogic($$, $request, new Response()) |> renderResponse($$) |> buildPsr7Response($$) |> emit($$); } */ > Suddenly I magically need to know how all of that procedural stuff goes > together just to be able to keep it short while calling all of it?!? > > I hope you understand now why I am still asking for real world examples > that are not based on endlessly bad code. "|>" is just a building block for simpler coding. It could be used badly, but it helps a lot. Procedural code could be much simpler and readable with "|>". function getRequest() { $config = loadConfig(); $dic = buildDic($config); $app = getApp($dic); $route = getRouter($app); $dispatcher = getDispatcher($route, $request); $businessLogic = dispatchBusinessLogic($dispatcher, $request, new Response()); $resp = renderResponse($businessLogic); $response = buildPsr7Response($resp); return emit($response); } "|>" version is much easier to read and write. I suppose most users will use it for easier coding, not for opposite. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net