Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93335 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95912 invoked from network); 15 May 2016 00:43:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 May 2016 00:43:03 -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:53553] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/55-48938-316C7375 for ; Sat, 14 May 2016 20:43:02 -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 762FE2002CB; Sun, 15 May 2016 00:33:09 +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> Cc: Zeev Suraski , Quim Calpe , "davey@php.net" , Larry Garfield , "internals@lists.php.net" Message-ID: <85ec320c-b8d6-1cc8-2059-7b8dfa6589e2@php.net> Date: Sun, 15 May 2016 02:42:42 +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 13/05/2016 à 20:16, Sara Golemon a écrit : >> for a potential solution to such a long-time issue as argument ordering >> sadness, IMHO, it's worth the pain. I am currently doing it and I'll send >> you the list when it is ready. >> > Awesome. Even if not used in this feature, it could potentially be > useful elsewhere. I hope you put it in a public gist or similar for > posterity. After a quick check of every functions available in the PHP distrib, only 55 functions should insert the lhs in a position different from 0 (first argument). From these 55 functions, 4 must not be used in a pipeline and, for the remaining 51, the lhs must be inserted as 2nd, 3rd, or 4th argument. The list and positions to use are available at : http://tekwire.net/joomla/projects/ideas/pipe-operator So, the logic would be : - if the function accepts 0 mandatory argument, it cannot be used in a pipeline, - if the function is in the table referenced above, use the position from the table, - else, insert the lhs as 1st arg. For internal functions, we can easily use some unused part of the 1st arginfo element to store the position. The default will remain 0, which doesn't require any change in current arginfo declarations. We'll just have to define a new ZEND_BEGIN_ARG_INFO_xxx macro with an explicit position. This macro will be used for the 55 functions requiring a specific non-default position. -1 will be used to mark a function as unusable in a pipeline. Once again, I think that argument ordering is a very important issue and, here, we have an unique occasion to solve it for a rather moderate price, since every functions have been audited. Another issue is caused by the sort functions returning the sorted array by reference. The problem is the same with or without '$$'. In practice, these functions cannot be used in a pipeline. So, either we change their behavior to be different when used in a pipeline, which is weird but allows an intuitive '|> sort() |>' notation, or we need to define a new set of functions returning sorted arrays. None of these is perfect but we'll have to propose a solution, as sorting is essential when driving an array through a pipeline. Regards François