Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97887 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89995 invoked from network); 20 Jan 2017 01:00:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2017 01:00:09 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.66 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.215.66 mail-lf0-f66.google.com Received: from [209.85.215.66] ([209.85.215.66:32876] helo=mail-lf0-f66.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/51-00729-51161885 for ; Thu, 19 Jan 2017 20:00:06 -0500 Received: by mail-lf0-f66.google.com with SMTP id x1so7041985lff.0 for ; Thu, 19 Jan 2017 17:00:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=OCxvKbArmhSiii0N4mWAJ0UEF5e7vLVkIHq+VhzSyrs=; b=l9JB5HplG0ixdcRZh8gQnskfo2vZh53cCQ9ljF/LvsxWeQxfx9HEPpFj4KIyt9tB0t zVyb1ptRDM3sq8YvLPJDp1YTXqwrPWUhXmL6yPnZDdBr0oX9+/GKrxaNPNJce/p530bp Z5mehP3Dmf/XMp0PXEkwmKJ03xrvGuDYrL+SkRlvJKGCBfSSKdGBxnvtWKovbTs9sziL dflMsxHXTIdIj+UsHPRIm4s4Z4oO+VKeP8pHwbBit52pq51gXosnNamijfGn3lGp8nwn HiuxSJrs3GZRkySd+EXcg2pTDMYT6ighEW1+/mtHouc/3lvJUDMKe+rbDlgx+/Vy+vBp 2NxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=OCxvKbArmhSiii0N4mWAJ0UEF5e7vLVkIHq+VhzSyrs=; b=MgHjibbcVe4kDESAhnJg3czQEVB/XTNPS4mG05TMH9Loz/lTKavMtl4SXPbji+U1HI ZtkNEBgJuLfQwFeql55H5dnEFYi9xavmLoAtSNDoXhBapxCQAe1m6ntRqWo7DOkWAFxu sErENXUhCk/HF9/AGeVR6Nq+OcTd0CZT0FqeRaJq2xae8IuF1dBaTGZ1sdS7kJCt/K0G 9/crC0kE+qTFip8WDkz8HtTTEfVq7CK9iTKIHHEwSYPW5EBWEQdESg4nMwPpc5yx88v3 /OYzEmvzudMeYwx8K8zoovkDMqH32/AWC8B8+xX7ks797XPV2Ai8td/ZmsVf8q0iR1LU 80Sg== X-Gm-Message-State: AIkVDXJKTYEFcYmG+nM9kH3/6ItbFTapj/PGr6HLqDMOmXkslz/okX32zLGlT5u7/s4PJETaxV8OMaJDTgz+8A== X-Received: by 10.46.21.25 with SMTP id s25mr5247955ljd.54.1484874000206; Thu, 19 Jan 2017 17:00:00 -0800 (PST) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.25.151.139 with HTTP; Thu, 19 Jan 2017 16:59:59 -0800 (PST) In-Reply-To: References: <3258a209-0b4f-aba7-370f-2d7bc2dfddfc@gmail.com> Date: Thu, 19 Jan 2017 17:59:59 -0700 X-Google-Sender-Auth: YEnEby9Px1BLW7-ScjGAh83Z1Qw Message-ID: To: Ryan Pallas Cc: Rowan Collins , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Pipe Operator v2 From: levim@php.net (Levi Morrison) On Thu, Jan 19, 2017 at 4:55 PM, Ryan Pallas wrote: > On Thu, Jan 19, 2017 at 4:08 PM, Rowan Collins > wrote: >> >> >> 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' >> > > See I don't like that at all, I hate having to put functions/methods in > strings, as find usages and refactor tools generally don't find the > strings. But sometimes I have to yield my preference to those who outrank > me (aka those with voting power) While this would be permitted: $str |> 'trim' So would: $str |> trim($$) I empathize that you don't like string-name callables (I really don't like them either) but this RFC helps avoid the string if you want to. Consider // without my proposal: array_map('trim', $input) // with it: array_map(trim($$), $input) Which makes a bigger difference for namespaced functions: // without my proposal: array_map('namespaced\func\map', $input) // with it (assuming you are in the correct namespace or // did `use function namespaced\func\map`: array_map(map($$), $input) So to summarize, the right-hand-side of `|>` being callable doesn't mean you "have to" put it in a string; you can pair it with `$$` to avoid that.