Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93328 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54423 invoked from network); 14 May 2016 10:34:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 May 2016 10:34:07 -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:5843] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0F/70-48938-E1FF6375 for ; Sat, 14 May 2016 06:34:07 -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 80BD5200342; Sat, 14 May 2016 10:24:11 +0200 (CEST) To: Simon Welsh , 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> Cc: Zeev Suraski , Quim Calpe , "davey@php.net" , Larry Garfield , "internals@lists.php.net" Message-ID: <25c7c17a-d5f5-10e2-c773-841d961a3b07@php.net> Date: Sat, 14 May 2016 12:33:47 +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 160513-1, 13/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 à 01:36, Simon Welsh a écrit : > I’m not fond of this approach. Take in_array as an example. I have, > in the same file, piped an array in as the second argument and > piped a string in as the first. To have the position of the piped > variable be implicit, you’ll need multiple versions of in_array. > > 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. Example : Imagine we decide that in_array() substitutes the $needle arg : $string |> in_array($haystack) Then, we create a function alias, named 'array_contains()', whose only difference with in_array() is that it substitutes the $haystack argument : $haystack |> array_contains($needle) This way, we can create 2 or 3 ways to call the same function with different arguments to substitute. Regards François