Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100796 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86201 invoked from network); 28 Sep 2017 21:57:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Sep 2017 21:57:35 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.52 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.52 mail-wm0-f52.google.com Received: from [74.125.82.52] ([74.125.82.52:55123] helo=mail-wm0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D4/12-60510-E407DC95 for ; Thu, 28 Sep 2017 17:57:35 -0400 Received: by mail-wm0-f52.google.com with SMTP id i124so7911wmf.3 for ; Thu, 28 Sep 2017 14:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=iwhH+56kGosnnHkluGp+UNgbb+FEee/zYYue+iqAFaA=; b=lUV1tkv7KZSIx9PXUuQhMs8WdyZWDYIj73QhdbIJkhM0Azoc4P4RnGofgxSk+KYM7h c7Uw4OMflyKFqf4t+ISuYF0Wh/dyWXZ66ukcO/m1vzSu8ZO043euRL2XPe/MuBJQ6Ir4 JUy66in39tvWJX8pCmJKPVY9EnbZ+C+rROTsx9ey9ZEJObItXZXiUttzMWyGPJ7RUqPS TzK0KMHD/zAzQkbbfOwEqiJK8PAA8OhJBg/UyPH8d5vrTz5k+QF6Pwpsk4oVz6Tz3oL3 I123KVd19YJy9b6kfHSFP8RzhuesYAEmqyke1xVqgBtt9uao3o1gyuz5P0ZlzcYu6eYB ndQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=iwhH+56kGosnnHkluGp+UNgbb+FEee/zYYue+iqAFaA=; b=b2xq98jqWW6+6IKoi4eFey9AAtJoEw3FVGb0Q9iXTnQMDll5dH6F9QcL265xSGE4QG cDQ+MpRu1wZWOK3vcrABmJniX+EWa8PWhHvT29Bdm/3vDVyOj/wJNwQJMoqirLFcg7g3 Ru8KexbYsvELJw8fmkjiH+/9v87cRTfBQtI8pE1uj2lxk4Z6X1BgrbRxWElGioUuHAIB 8xwPfq21rTGDBB5KU3MIT1WCPsHQx8QOoZjce0o2dfglNdpBnc5gsp10xkWzzhwz6CXK y0UQa1ruQnPUasTKQOIMjAY/ve5yppTXR7nXyTufrnmuutsco07A7rFrA28DP6a0ZQcj 3oQw== X-Gm-Message-State: AHPjjUgcFcHgK2V79WrzielaRT3la0jEnQDGE4chXOlUIxIccGcYe83A ijo34Sd6bO4njuL9q5dQedmQLA== X-Google-Smtp-Source: AOwi7QCEyyYqqmDk9n8w2eylHWbJj6ShyZ4OVPJoWyQkfuHqz89Ctn8BgCbBR1WnQBE5KmyBfx4O+g== X-Received: by 10.80.174.68 with SMTP id c62mr7438637edd.238.1506635851535; Thu, 28 Sep 2017 14:57:31 -0700 (PDT) Received: from ?IPv6:2a00:23c4:4b81:ae00:c00f:5931:abee:2f06? ([2a00:23c4:4b81:ae00:c00f:5931:abee:2f06]) by smtp.googlemail.com with ESMTPSA id b30sm2768422ede.1.2017.09.28.14.57.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 14:57:30 -0700 (PDT) To: internals@lists.php.net References: <98e7fff2-72ac-0430-72bb-099a021626f6@gmail.com> Message-ID: Date: Thu, 28 Sep 2017 22:57:28 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Pre-draft for PipeOp v2 From: rowan.collins@gmail.com (Rowan Collins) On 28/09/2017 20:07, Levi Morrison wrote: > The brace style is concise, nicely delimits the > expression, and seems the clearest for me to read because the symbols don't > dominate. This is something that I tried to push for in previous discussions - I've never liked the syntaxes where the expression floats away from the operator, and you have to work out where it ends. The counter-argument I got was that some people actually like writing things like this, although I'm not entirely clear why: fn($x) => fn($y) => in_array($x, $y) Which brings us to the question of how we might generalise the {} syntax for more complex situations. Clearly, we can't just nest them if the first parameter is always called $0: { { in_array($0, $0) } }  #WAT? Obviously named variables are kind of useful anyway, so maybe $0 could be the default, but allow them to be specified: // Simple definition { $0 . ' world' } == { $greeting => $greeting . ' world' ) // Nested definitions { $x => { in_array($x, $0) } } == { $x => { $y => in_array($x, $y) } } // 2-parameter function { $x, $y => in_array($x, $y) } > My impression from the community is that the pipe operator is desirable but > not if it encourages string or array callables. Yeah, my first thought on this thread that I liked this version of the proposal significantly less than the previous one, because I always liked the idea of this being a programming style, with the RHS being a statement to be rewritten. So you could write $input |> $foo = $$ |> echo $$ |> return $$ ... But with a suitable way of creating a callable to pass to it, I could live with it. What if the syntax for taking a reference to function was just a special case of the partial application / lambda syntax? At risk of turning into Perl, we could use "$..." to mean "copy in all the parameters": $foo = { in_array($...) }; This would be logically equivalent to: $foo = function(...$x) { return in_array(...$x); } But the compiler could actually optimise it as something more like Closure::fromCallable('in_array') Just throwing some thoughts out there to see if any of them stick... -- Rowan Collins [IMSoP]