Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97885 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83300 invoked from network); 19 Jan 2017 23:08:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jan 2017 23:08:49 -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.50 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.50 mail-wm0-f50.google.com Received: from [74.125.82.50] ([74.125.82.50:34182] helo=mail-wm0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2B/50-00729-10741885 for ; Thu, 19 Jan 2017 18:08:49 -0500 Received: by mail-wm0-f50.google.com with SMTP id f73so9541410wmf.1 for ; Thu, 19 Jan 2017 15:08:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=kUlKd4PKN9ulxdVTnkTDsC4+Ib90Ne3MPGybim00wMo=; b=NiI4GWY1JpM5AC2mJmLgH+/gaJ86QGWuahdKvPuPD3UjrEcKqYaOn5d5AWkxO48FOC 8Nh+mBsfUoVLPOsjlrrB5nal+l4JB3rtxdXnzdtk4Zxt3k3doIyhPXnpvYdWAlZMx7yO aCPHufDukBr8CQoVt2LPsxQfp+m0bTJBrPWd6oWdkHF77d6OAEGuXx76KDoFmR3bwJ9H iRt8gOF1ksC0edyg/ksVnggb6tuZfyidIzO35lLA8Ho0V+Va1uSt2vYhQEKrFRU4pwxT GJhVN17Mwi9JdsT7pI5HbISK5TywKSdaU2EOy380crM0bZnrXNaeCv0FxNQk9Migy+wa DK3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=kUlKd4PKN9ulxdVTnkTDsC4+Ib90Ne3MPGybim00wMo=; b=qmsqybRvvaDqITAPLes7wC0tuFOz8yIqWkWj9oWpuhX/pw+Y9BYg0gSdT7SVTMy3jK Uvpss+rWUiCGYw9SejzB00Twwuyz8k0aRISR+mnY/fVdfKDO3P4xemXq8tQ4jXQ1Vncx 6UUQ4PyMQUasyGGpYn6sxoYwbYWbK5DfJrp6YvViM/+KgyVX9P3+IuqP7Df6rLXVoWDq rHFIGHmcqHXwU3kqjhYhNij4q9jAvUT+YzJWH1E1/s0Eeb9hV6UIHWm1n4PSEga8RLT3 c+CiRXuycM1uwC2MdmF5YMes+6l/ueNDQrVvOPIF8zFyTJ6Egq4vhMBRO6ZgV51S1IuA lFug== X-Gm-Message-State: AIkVDXJ0UKJ54Jdn5Pedqc9NxesyNx2i+s0hhqwWkvWkQe+7ZLy2/3sWLnutef89nQQ23A== X-Received: by 10.28.213.133 with SMTP id m127mr1096686wmg.90.1484867326175; Thu, 19 Jan 2017 15:08:46 -0800 (PST) Received: from ?IPv6:2a00:23c4:4bd2:6e00:dc:9eee:7014:97d0? ([2a00:23c4:4bd2:6e00:dc:9eee:7014:97d0]) by smtp.googlemail.com with ESMTPSA id w18sm1538119wme.9.2017.01.19.15.08.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jan 2017 15:08:45 -0800 (PST) To: internals@lists.php.net References: Message-ID: <3258a209-0b4f-aba7-370f-2d7bc2dfddfc@gmail.com> Date: Thu, 19 Jan 2017 23:08:35 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Pipe Operator v2 From: rowan.collins@gmail.com (Rowan Collins) On Thu, Jan 19, 2017 at 5:54 AM, Levi Morrison wrote: > I've talked to you about this RFC off-list, but I figured I should > mention it on-list as well. I think we should make `|>` and `$$` two > independent operators that work well together (rather than only > together). Firstly, Levi, can I say I really like this line of thinking at first sight. As long as we can avoid it becoming too cryptically Perlish... On 19/01/2017 22:17, Ryan Pallas wrote: > > When you say assert the right hand side is callable, does that mean to > call an object method, you would do [$obj, 'method']? What about functions, > is it just the name like $str |> trim, or is it $str |> trim()? This is a good point. The difference between the pipe operator as proposed by Sara and the combination of two separate operators is that in Sara's proposal you'd always write this: $str |> trim($$) But in Levi's proposal as I understand it, the right-hand side is not syntax, it's just constrained to be callable, so the simpler (but rather ugly) form would be: $str |> 'trim' On its own, trim($$) rather pointlessly wraps a function with one argument into another function, still with one argument, effectively short-hand for Closure::fromCallable('trim') [incidentally, fromCallable isn't actually listed in the documentation yet]. Since ($$) would leave a closure effectively unchanged, you could actually write: $str |> trim($$)($$)($$)($$) And interestingly, the $$ magic couldn't be used to turn a function with one argument into one with zero, because trim($$)($foo) actually executes the function. This all feels fiddly for the same reason I dislike generators being introduced with "function" rather than their own keyword: it's one syntax hiding behind another. Which is a shame, because as I say, I liked the general idea. Regards, -- Rowan Collins [IMSoP]