Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93000 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61024 invoked from network); 30 Apr 2016 19:44:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2016 19:44:01 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.171 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.192.171 mail-pf0-f171.google.com Received: from [209.85.192.171] ([209.85.192.171:33808] helo=mail-pf0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/1F-58459-FFA05275 for ; Sat, 30 Apr 2016 15:44:01 -0400 Received: by mail-pf0-f171.google.com with SMTP id y69so61971531pfb.1 for ; Sat, 30 Apr 2016 12:43:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=IIBWGVL2O2hXAF5CKea3rSuOZMY0AL2iyHZQzekIEF8=; b=K/JI28nSiNi0/iIXyTTtAa8thJxGvGH71waF36ozR+WKD+tq8phssJELmrrtPeIhSq zzN3N/BRk1a2bPh9zAh34ICC+JajR9lolqEvSh6vAe0Yo7wMWxJNnbRmzJUJgicFXGy9 fefh2W/gOgBfu6dROR1RJ2zA5hDcEfRHhdoisDFNDSuIKj1PvSKv3aonpYWuXQnhIG1n 8gI96shTL1cnZPMSLxerdE8KPXWlfaNvVJnN8pfNZI8cb4auO0ChVGKyyLjX0CboJsXD ZpeSoER+GqhsKjrb3UjrEIbUfRh/IAcbHnxpuJcuywiKgDDXrSTvyM3u+CmoqN+cBfFQ rxPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=IIBWGVL2O2hXAF5CKea3rSuOZMY0AL2iyHZQzekIEF8=; b=nDywE7DbRaeB+clbRGRHNUgBblLxLCCe7aBL/nFUXBclaUFpVeHjLHsRHlxvwOSit8 f9JspSFOahqzxz8aEnc741FaFpz6jUowOcNtliTRCV3NODf3G2fk/sPGoykZl9F5fgcw gxM+RFJBiTMIhCFiY0Bm6LTUw5+6wR0Jt1N3stvcSYGvDWDK7sDKMfQDyReGMD3Z/SSb RXN5WSAc3avuF2qhZU9TDxVFOVxjcYhp6VjF1lVRxXxBWwOxAzoFEN8s+N1PHm2/5IM0 1qhNRWERzyD0zwelny0JsDuhaGuVh6i1/oaDsRRa9gaiWfx8Tp0A7uBz24S0dy9qft6c S7eg== X-Gm-Message-State: AOPr4FUakKV1nde6RZH1ORJr9Usy8HH1J+i6KwWx/yuSUOdXv8AqesP5rgPAzMzsN9Nuuw== X-Received: by 10.98.15.142 with SMTP id 14mr39007216pfp.6.1462045435846; Sat, 30 Apr 2016 12:43:55 -0700 (PDT) Received: from Stas-Air.local (76-220-46-95.lightspeed.sntcca.sbcglobal.net. [76.220.46.95]) by smtp.gmail.com with ESMTPSA id v185sm566119pfb.72.2016.04.30.12.43.53 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 30 Apr 2016 12:43:54 -0700 (PDT) To: Larry Garfield , internals@lists.php.net References: <8ea990da-1fe7-256c-4e08-0b30715c8e8a@gmail.com> <5724F3F8.5070909@garfieldtech.com> Message-ID: <5637f0b4-c72f-688b-f799-21b8ecc3dc18@gmail.com> Date: Sat, 30 Apr 2016 12:43:48 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <5724F3F8.5070909@garfieldtech.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Pipe Operator From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > See, I take that quote in the exact opposite direction. I find chaining > methods to be far, far less "clever" than deeply nesting them inside If you tell me that syntax like "foo() |> bar($$)" is more natural or intuitive or readily understandable to anyone with any programming and PHP background than "$fooResult = foo(); bar($fooResult); " then we indeed have exactly opposite understanding of what is natural and intuitive. I think that overly clever is inventing cryptic syntax to save a couple of keystrokes and rearrange code in unusual pattern that looks unlike the code used to look before and resembles some other language (this time it's F#? how many languages PHP should be at once - can we get a dozen?) > each other. We shouldn't force pointless intermediate variables on Why you think they are pointless? And you do produce them, you just hide them behind $$ so you can not actually neither check them nor understand which value goes where without tracing through the code with your finger. > people for the sake of readability. The fair comparison is the deeply > nested version vs. the chained version, and in that comparison the > readability of the chained version is far, far better. No, it's not a fair comparison. You shouldn't do deep nesting, and you shouldn't do cryptic syntax either. Variables are not evil. They are there to make things easier for you. Use them. > intermediate variable to analyze and nothing has changed. However, > passing an array to array_filter() then passing the result to > array_map() is always type safe (because array_filter still returns an > array even if it filters down to 0 items), and array_map on an empty > array is essentially a no-op, so I'm comfortable doing so, and wish I > could do so more often with less fugly syntax. :-) I appreciate the careful choice of the example on RFC - indeed, in some very carefully chosen cases (mostly with arrays) you could get away with chaining without getting into trouble. In most cases where it would be used, though, that would mean not checking for errors, forgetting corner cases and so on. And that's how people would use this, because none of the existing functions were developed to work with this pattern, so you can only get away with it due to luck. In strictly typed languages like Haskell, they use types like Option and Maybe to enable this pattern - essentially, to enable functions to operate on more than one simple type of value. However, it doesn't look in place in PHP, and it would require much more deep restructuring to actually make it work than just having |> as an operator. > of promises", but more "is there something we can do here to be forward > thinking, since lots of people want to see async in core PHP?") I'm not sure what promises have to do with inventing strange syntax to pass result of one function as a parameter to another. -- Stas Malyshev smalyshev@gmail.com