Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97890 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14863 invoked from network); 20 Jan 2017 10:53:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2017 10:53:28 -0000 Authentication-Results: pb1.pair.com smtp.mail=flaupretre@free.fr; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=flaupretre@free.fr; sender-id=unknown Received-SPF: error (pb1.pair.com: domain free.fr from 212.27.42.4 cause and error) X-PHP-List-Original-Sender: flaupretre@free.fr X-Host-Fingerprint: 212.27.42.4 smtp4-g21.free.fr Received: from [212.27.42.4] ([212.27.42.4:63031] helo=smtp4-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D8/E2-00729-72CE1885 for ; Fri, 20 Jan 2017 05:53:28 -0500 Received: from [172.16.0.12] (unknown [158.255.108.131]) (Authenticated sender: flaupretre) by smtp4-g21.free.fr (Postfix) with ESMTPSA id 158E819F603; Fri, 20 Jan 2017 11:53:20 +0100 (CET) To: Levi Morrison References: Cc: Sara Golemon , PHP internals Message-ID: <52a7238f-af22-8960-c829-b1d4ba1bbfdc@free.fr> Date: Fri, 20 Jan 2017 11:53:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; 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: 8bit Subject: Re: [PHP-DEV] Pipe Operator v2 From: flaupretre@free.fr (=?UTF-8?Q?Fran=c3=a7ois_Laupretre?=) Le 19/01/2017 à 22:53, Levi Morrison a écrit : > On Thu, Jan 19, 2017 at 11:12 AM, François Laupretre wrote: >> Le 19/01/2017 à 13:54, Levi Morrison a écrit : >>> The `|>` symbol would be the piping operator with these semantics: >>> 1. Evaluate the left-hand side. >>> 2. Evaluate the right-hand side. Assert that the result is callable. >>> 3. Pass the result from 1. as the single argument to 2. >> >> May I suggest extending your 3rd rule to : when the right hand side has the >> form of a function call, insert the result from 1. as first argument of 2. >> This way, right hand side may specify additional arguments > If we only had `|>` this may be good but since we are also proposing > `$$` then this renders your suggestion unnecessary: > > $string |> trim($$) > > Would work just fine with no performance overhead. > > Additionally, you could write: > > $input |> array_map($fn, $$) > > Or: > > $input |> array_filter($$, $fn) > > Basically, `$$` gives the flexibility of passing additional arguments > and keeps `|>` simple. No need for additional rules for `|>`. Right, I just suggest to make the '$$' optional when used as first arg of a rhs call. Except complex cases like array_xx() functions which will generally require an explicit '$$', most cases will feature a '$$' as first arg of a function call. This may be considered as better because more explicit, but I think the case is prominent enough to justify this 'shortcut'. Another question: Will you accept several occurences of '$$' in a RHS ? Last, a cosmetic suggestion : replace '$$' with '$<' (more explicit as 'input data', imo). Regards François