Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93001 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61246 invoked from network); 30 Apr 2016 19:44:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2016 19:44:11 -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.220.46 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.46 mail-pa0-f46.google.com Received: from [209.85.220.46] ([209.85.220.46:33107] helo=mail-pa0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 30/2F-58459-80B05275 for ; Sat, 30 Apr 2016 15:44:10 -0400 Received: by mail-pa0-f46.google.com with SMTP id zm5so65495125pac.0 for ; Sat, 30 Apr 2016 12:44:08 -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=MLYlMjULAWVZBBrMgwK8Ze9UxYmBZnMekhs25ZlzDoXwYPzyFF1eL8Gx/jbh+MjZvT gSPpIiT+3pHpB2l8ABzL9iYVk9drajCzymooWESkj6EqiH7pAErAlcZkYe+54TOTteXg 71QWJcI32N3BjswnUVES6Rj/FszAx2FVwF/dXCtMsBHUrHrlCt1048+MrLwq0syBS8aE W5OA/zmqsRIl5O+VaRn0eYtV8JFlNQ0M4KYSVzChQUiIdf3PcSpHm1ZO0abUAutOrLgh UCR2+FKKrasG2cvvR3vcJA024IZ/CF1/4Rtk99Sr2qwUnKi7RZgoUDTkWDodWbGgndhV 3AdA== 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=VZ7crBKqefVuQ/LLuSZkVy3agA+oUMe2FVZXtS3LFBUzU54eYlbf8HWwB/0YHjaNOp R/ggSWFrOVZlvjkMfbAhs1WfQ4ucZegYvfVWBHIoMRd1H8VDQ0j1RS35NjuUXz1oRHpv 1uHF52sfrBZP3ZfwUqCl5JzCrmBDH1SsFf7Uhkc/HvYiNmhiihnP1yfrxRqczDkyC+AD XB9Iuky4e3xtojGQyNLJS5IiReJfVzhDRku9HCDdi+XL0piAjSZeTnpYwTPzVKrANG5U Gl4fcd5HtZkSrJT3HJMyPsUnZVY5gv2sy7hr4fvH2phRSTzdYqG6KiKr7ba80qxd7P9p fieQ== X-Gm-Message-State: AOPr4FWUUx/d6ihGXgHE/+ZNYT7r2biQcoF4Bx3EwTRo4wOtW2gbqhk8Ww2ZPACvSDsJEg== X-Received: by 10.66.82.8 with SMTP id e8mr13641271pay.124.1462045445654; Sat, 30 Apr 2016 12:44:05 -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 184sm33269292pfd.43.2016.04.30.12.44.03 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 30 Apr 2016 12:44:04 -0700 (PDT) To: Larry Garfield , internals@lists.php.net References: <8ea990da-1fe7-256c-4e08-0b30715c8e8a@gmail.com> <5724F3F8.5070909@garfieldtech.com> Message-ID: <58dddd34-21a7-2816-f825-5a792f2da0ba@gmail.com> Date: Sat, 30 Apr 2016 12:43:58 -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