Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93319 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8180 invoked from network); 13 May 2016 18:16:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 May 2016 18:16:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.215.45 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.215.45 mail-lf0-f45.google.com Received: from [209.85.215.45] ([209.85.215.45:35632] helo=mail-lf0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/E5-01216-4F916375 for ; Fri, 13 May 2016 14:16:21 -0400 Received: by mail-lf0-f45.google.com with SMTP id j8so91946399lfd.2 for ; Fri, 13 May 2016 11:16:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-transfer-encoding; bh=+JMqWZMw4SgNj4DDTLV83k/W3K0mQSAheUsXW78aL/M=; b=LVfA95wcA5q2clT2lFNqRnhhvKdmWUdbS6SlTf+mEYl74cA05U+l0x+rwhovPF04BT ZQA1a8G742cwLesHMfH0W0EyQkLEBYmIf38Lumr8HiITnBf+gXRsJAP9MdFgvFkn9g+Q RuUuYVOGLH+N2aGoS/PdT5yKmyypO6ZQH/PJI4wTgoq3lQ/Ko9v8mErBk/nhuZaAGLvK UyG6mjqyCeGl2zq3SfsIg5lZ50+MfBXnzemGmDmKBF1L+jvmFXOryF53STwfAMAV/6bL oCO4iBQIugK9sYkGnYR2cjlHJZKJUiO8onLGH4JiddE9yG5ysfgDcdPp/LIWrHM9eG1P G++A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-transfer-encoding; bh=+JMqWZMw4SgNj4DDTLV83k/W3K0mQSAheUsXW78aL/M=; b=gHaOyjn4W5AVMCYs+3mfWSXrq40jDUrb1uSUTT6ysOxnpO1ugulMKgjAZtSZtxw8wH sqWaqCBuxPvOUR2q7uNOfgQ+AcGYxn7EcilWToe9VvNjs1s3nr5RG51r0dqajtrAYeZ6 JbvSDrs9ygLXbcSpca5cb2V+eyaC6IpvbZ+TJyLPM1U4wo3p0iageUOX7JUUkwkypeoV nXVDs6WZSLYw7UQUwhWLggPUpZKxaa5aKgVnC7WBfmVaAhtJu1CN3pqiEcIvjYHzWyX+ is+Vw8i4zXiGnfA6nSNFNaNUmdPkqBDIzFB2nmlTJUXy4CrGIsSfaicZaQ7Hzm1wt9uR TuOw== X-Gm-Message-State: AOPr4FWku5bnZ+o85aWlLuMhnAp70F444XwGIsflE1Kif59N8SN6uTfRpJ7ezAVkvdCNC+Zog4MSl/FvzakcPA== MIME-Version: 1.0 X-Received: by 10.25.146.6 with SMTP id u6mr6289606lfd.60.1463163378148; Fri, 13 May 2016 11:16:18 -0700 (PDT) Sender: php@golemon.com Received: by 10.112.19.72 with HTTP; Fri, 13 May 2016 11:16:17 -0700 (PDT) X-Originating-IP: [107.198.91.68] In-Reply-To: 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> Date: Fri, 13 May 2016 11:16:17 -0700 X-Google-Sender-Auth: bdEaOSj87Qxoq4DCcXfqRI_l6q4 Message-ID: To: =?UTF-8?Q?Fran=C3=A7ois_Laupretre?= Cc: Zeev Suraski , Quim Calpe , "davey@php.net" , Larry Garfield , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Pipe Operator From: pollita@php.net (Sara Golemon) On Fri, May 13, 2016 at 10:18 AM, Fran=C3=A7ois Laupretre wrote: >> So we'd have to audit all 4k+ functions in the PHP runtime (and >> provide a mechanism for defining it on userspace functions)? > > That's right, except that, if we only consider functions accepting more t= han > 1 arg, we just need to check about 1,000 functions. It may seem a lot but= , > Having been a large part of the audit for PHP6, I'd say "Yes, it definitely seems like a lot, and is." :p > 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. > For userspace functions, the logic can be quite simple : 0 arg -> not usa= ble > in a pipeline, 1 arg or more -> substitute first arg. Then, we have 4 > options : > - consider that, when using a userland function in a pipeline, th= e > lhs is always inserted in 1st position, > It would feel weird that internal functions can deviate from this rule, but user-space functions can't. :/ > - provide a function to change the position on an existing functi= on > (default =3D 0 when function is registered). A negative position would di= sable > using the function in a pipeline, > Feels like a hack, but I suppose if it were part of Reflection it might make sense... (new ReflctionFunction('my_func')->setPipeArgPosition(3); > - enrich the syntax of function declaration to designate the arg = to > substitute. > This would be a good application for User Attributes: <<__PipeArg(1)>> // Zero based, obv function array_map(Callable $fn, array $arr) {...} > I would propose to start with the 1st choice. After people have the occas= ion > to use it for a while, we will see if an additional mechanism is requeste= d. > That's not unreasonable if we're starting from a place of assuming that invisible substitution is the way to go. I'm not convinced, but I could be. Just to verify, you're suggesting an end-state something like this? $ret =3D array(1,2,3) |> array_map(function($x) { return $x * 2; }) // lhs implicitly passed as second arg |> array_sum(); // implicitly passed as only arg (first position) // $ret =3D=3D=3D int(12) -Sara