Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93334 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88329 invoked from network); 14 May 2016 21:18:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 May 2016 21:18:43 -0000 Authentication-Results: pb1.pair.com header.from=francois@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=francois@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 212.27.42.2 as permitted sender) X-PHP-List-Original-Sender: francois@php.net X-Host-Fingerprint: 212.27.42.2 smtp2-g21.free.fr Received: from [212.27.42.2] ([212.27.42.2:19662] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1E/C4-48938-13697375 for ; Sat, 14 May 2016 17:18:43 -0400 Received: from [127.0.0.1] (unknown [82.240.16.115]) (Authenticated sender: flaupretre@free.fr) by smtp2-g21.free.fr (Postfix) with ESMTPSA id CFF44200390; Sat, 14 May 2016 21:08:47 +0200 (CEST) To: Sara Golemon References: <452ddb93-1f47-1d0f-4f24-bedbff506b27@gmail.com> <98.61.11104.A1D41375@pb1.pair.com> <7c94ca37-e188-dd2b-a66f-bb63bf03041a@gmail.com> <1463008795.1856219.605250569.74618FC4@webmail.messagingengine.com> <92E7F8A8-0845-48A7-91B1-9554C5F66C9D@zend.com> <879feadf-c04e-c0de-826b-110b3eb4e22f@php.net> <25c7c17a-d5f5-10e2-c773-841d961a3b07@php.net> Cc: Simon Welsh , Zeev Suraski , Quim Calpe , "davey@php.net" , Larry Garfield , "internals@lists.php.net" Message-ID: Date: Sat, 14 May 2016 23:18:21 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Antivirus: avast! (VPS 160514-2, 14/05/2016), Outbound message X-Antivirus-Status: Clean Subject: Re: [PHP-DEV] [RFC] Pipe Operator From: francois@php.net (=?UTF-8?Q?Fran=c3=a7ois_Laupretre?=) Le 14/05/2016 à 18:35, Sara Golemon a écrit : > On Sat, May 14, 2016 at 3:33 AM, François Laupretre wrote: >> Le 14/05/2016 à 01:36, Simon Welsh a écrit : > \>> Sure, you could try to use the type of the value being passed in, >>> but that ends up much more magic and then you run into the same >>> problem with strpos, or password_verify, or a variety of other >>> functions that take multiple of the same type of argument where >>> order matters. >> >> Right. Some functions may have several potential arguments to substitute. In >> this case, I propose we choose a position to use when the function is used >> in a pipe and, then, create function aliases with different positions. >> > This doesn't strike you as massively over-engineered (and magic) > compared to letting the caller explicitly specify position? > > Moreover, it only "solves" the argument ordering problem by replacing > it with a function alias selection problem. No. Not *massively* over-engineered because we have only few cases. More than 95 % of existing functions provide only one potential lhs. So, yes, we would have to create some function aliases, but I estimate we don't need more than 10 to 20 overall. So, on one side, I solve the argument ordering problem for 2,000+ functions, and on the other side, I probably need to create about 20 function aliases. IMO, the balance is still positive. Another point is that we don't need to create an extensive set of function aliases immediately. ATM, we just need to choose one lhs arg per function. Then, in a future version, an alias can be proposed if another potential lhs appears useful. I'll take strpos() as an example : IMO, the 'natural' lhs is $haystack. This allows to release the 'pipe' feature without creating anything else. Then, in a future version, if someone wants to propose an alias which would use $needle as lhs, it will the object of an additional RFC and we'll discuss the alias name, and whether it is really needed or not. Regards François