Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93272 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67184 invoked from network); 12 May 2016 12:34:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 May 2016 12:34:13 -0000 Authentication-Results: pb1.pair.com header.from=quim@kalpe.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=quim@kalpe.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kalpe.com from 209.85.223.172 cause and error) X-PHP-List-Original-Sender: quim@kalpe.com X-Host-Fingerprint: 209.85.223.172 mail-io0-f172.google.com Received: from [209.85.223.172] ([209.85.223.172:34868] helo=mail-io0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/BD-28272-44874375 for ; Thu, 12 May 2016 08:34:12 -0400 Received: by mail-io0-f172.google.com with SMTP id d62so92570094iof.2 for ; Thu, 12 May 2016 05:34:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalpe-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=9eyHxj5O7i3bYtHIwsrIrwkqAd3mvRkpY4M0PB0UWnU=; b=rfXpFzFi2ygOx5c+Bi0PYeB6ZXmMZHxOWwzulOFTZHxC7+/Czg6TR0WCvI5kcuMd6K ekjGYAumw6ITrCXynvLZz5kV09YItZl/gMmTIavST/Xfy26HqmnU9I92NfpeBDaxXMc0 ReVkRqhEaMsS+9JZtUaR4SHFrZoWZAJNfXyOCw+4E1iopfIwq2hOWw3Cxsi29jfsOerz 2jlYX4yhl+c7+jDjYA1Vb+9WC7XDHhQ4nlc6yqdFRr1W8MO0xSOPD0nvGijigbPigPtb 6byT+qpNrItATHldO1z+G7JCdBH9axtKZE3SOGTl6YU1W8MbFr5e7MQd4Mcf14L6Lw8M x+4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=9eyHxj5O7i3bYtHIwsrIrwkqAd3mvRkpY4M0PB0UWnU=; b=KBMAfhFgwg3yVeDGJWm3IAJoLRak+cnB6WueKZKE/8rRDMdyIxIKPAFPH/ZTcDmWvL +kegrAEQJh7cjPw3SucQufZZz/2FiyWM7sOQt2L4ukiNYkfaTW22hjoNWJOpRUSOwlfq +5iuoX4ZI3ZjBCI96kRjUKcIxlQsCylwUUKL6OSB/VXwGAbGckKdgXfTEeX3g8vUQDg1 SemIVJYvekhZGpbLdasEg2oY7auZFr5nw437vA5f+PkIgd/nVeEhNSmnOsTVTQC8AE3S sE6crurerCmC3lFpmQFqNSRkWo92eHzrBXlCrQ6+y+lKN/yL7psFZDog1YIQf++QsF1w XyMQ== X-Gm-Message-State: AOPr4FUIsxZeXymNYxhyvm/rWcA3O/D5f1doURgfTbqP1CSD6NdRsn5kjCydO7d95tJuXu4EdyRe/R+Drsytqg== X-Received: by 10.107.9.232 with SMTP id 101mr8220813ioj.52.1463056449646; Thu, 12 May 2016 05:34:09 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.220.194 with HTTP; Thu, 12 May 2016 05:33:49 -0700 (PDT) In-Reply-To: References: <39071a01-a42c-0952-b3a8-b4769c79b56b@fleshgrinder.com> <0ac3be89-6fb4-610a-ef89-0928f264f96c@fleshgrinder.com> <71379db5-b7b8-78b3-ada5-eee34e6e22d6@fleshgrinder.com> <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> Date: Thu, 12 May 2016 14:33:49 +0200 Message-ID: To: Davey Shafik Cc: Larry Garfield , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a113ecdbef7ce710532a45f60 Subject: Re: [PHP-DEV] [RFC] Pipe Operator From: quim@kalpe.com (Quim Calpe) --001a113ecdbef7ce710532a45f60 Content-Type: text/plain; charset=UTF-8 On Thu, May 12, 2016 at 12:33 PM, Davey Shafik wrote: > On Thu, May 12, 2016 at 1:19 AM, Larry Garfield > wrote: > > > On Mon, May 9, 2016, at 10:21 PM, Stanislav Malyshev wrote: > > > Hi! > > > > > > > |> seems like a common symbol to use, but it admittedly does look a > > > > > > So, usage in one semi-obscure language (F#) and one completely obscure > > > one (Elixir) - Clojure doesn't use |> - and one proposal for Javascript > > > now qualifies for "common". And that counting the fact that neither of > > > them actually uses the worst part of proposed syntax - magic variable > $$. > Is $0 being considered? It's not ideal but is used as "pattern match reference" in preg_replace, so we have a (sort of) precedent here. Same for $1 (first capturing subpattern). > > > > -- > > > Stas Malyshev > > > smalyshev@gmail.com > > > > If the issue is $$ feels too Perl like, what is the alternative? Is > > there another way to chain methods cleanly? > > > > In a sense, what we're really talking about here is continuations. > > Continuations (over-simplified) are a clean way of setting up "run this > > function, pass its result to this function, pass its result to this > > function, etc." That makes composition really easy. |> is essentially > > a continuation syntax. The $$ is to work around the fact that PHP > > function can have an arbitrary number of parameters, whereas > > continuations work best with single-parameter functions. > > > > Of course, with currying any multi-parameter function can be reduced to > > a series of single parameter functions. So what if we were to limit the > > concurrency syntax to single-parameter functions? And if you want to > > reduce a multi-parameter function to a single parameter function, yay > > closures. > > > > Would that limitation help or hinder? > > > > Either way, I firmly believe that more functional-friendly capabilities > > like continuations, promises, etc. are a direction that PHP needs to > > move, and syntax in that direction is valuable. > > > I wonder if it's possible to use $$ only when it's necessary to pass in the > argument positionally, that is, if it's not used on the right hand side, > it's passed in magically as the first argument, otherwise it's passed in > wherever the $$ (or whatever other placeholder you want) is used. > > _OR_ we just prepend it to the argument list used on the RHS. I noticed > that Closure also have ->> for passing in the argument last, vs -> for > first. I'm not sure I would like to have |>> for example. > > I think that $$ as a positional placeholder gives us the most flexibility. > $$ is super easy to type, apparently is possible with little conflict to > existing syntax, etc. > > I'm +1 on |> and $$. > > - Davey > --001a113ecdbef7ce710532a45f60--