Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100707 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94493 invoked from network); 19 Sep 2017 22:46:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Sep 2017 22:46:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.177 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.128.177 mail-wr0-f177.google.com Received: from [209.85.128.177] ([209.85.128.177:52817] helo=mail-wr0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F4/22-62331-B3E91C95 for ; Tue, 19 Sep 2017 18:46:19 -0400 Received: by mail-wr0-f177.google.com with SMTP id c23so765582wrg.9 for ; Tue, 19 Sep 2017 15:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Y0EuYtsmVMAFS0Iili9Vz3ALEUWzCetOutFF54AT48U=; b=bkjnyk0dYisxjOucwju2nzSUPY4nEW4xLrxmrLCCjEqotTY+4gotGsgYr3ypRrZJnm sl2+X+dPjSd3bRy256EES2Z1vnByu6Z81yKCuMGvpml5QorHOUJSnY2TNfSnyFlkO5ed ghtvp+i5szNPz45Qi5mvC+kP6yNCZHS3tYs8+uN4GV60RG6i25xM3fpBX95qNEZO9FyH FzC2JtXO4pE+YNdBFGffc7cHRODuwtlYDneTMFFq3a3Y/neKfI7y4ihF9eXPq8ZEDK4d xtXYYsmNWvyLZj5HRUoBTI6KBEIXDk5J8EAD5pOU7oVO1t4LXPi6CvmoPUqwwuKNFrDl i2Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Y0EuYtsmVMAFS0Iili9Vz3ALEUWzCetOutFF54AT48U=; b=mHBezLoUNnvFyVaKyfNpbQH7P9oTjDPtvtWQ9zeu+R6t6ysFOzIjFl2gjQhoYRKGiv 7mwJ5AVUoiZbAF9cyFhSAGtqJ7hVgFP6OBDQzuBOwGPe3K6x5h81ZSb+h3a8RDD7JFbv yfugbS83Ep1U5MmtwePDAq1NMLaig89G1EYfpEERCSNQugTGS8PJPtn/ZRDKGCxS46c1 oydu93NNTvPSMIVyTku1yTWHLILxcZi4GNO/8bPzJu/yI+HauVLyzuKRC7j6lpnDG+rD ig5dXINO5q2XYtogm8LhkWvs+tMrx+pm1UBspwofVO2Hwn/ZPVdAOU91fg4dMtIsazIP d9LQ== X-Gm-Message-State: AHPjjUgzRGTnVNb0Ml95Opytv8YHQtWk5XJ2opcbz52djyVxA/bVW+4D b0KuuX/ZmQO/IGd0yA2qtvTHTjDvYPxL+MjfjM7mRA== X-Google-Smtp-Source: AOwi7QBBwlExBFsAR0bRImgOFrL2WlNVj5pk/YLp2M3Co429nnDDvIBJ/QhYIOcuiv69ggqqlumhZcaaJ1M5DgxoRBY= X-Received: by 10.223.136.119 with SMTP id e52mr2422988wre.225.1505861176630; Tue, 19 Sep 2017 15:46:16 -0700 (PDT) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.28.193.130 with HTTP; Tue, 19 Sep 2017 15:46:16 -0700 (PDT) In-Reply-To: References: Date: Tue, 19 Sep 2017 16:46:16 -0600 X-Google-Sender-Auth: NLsY9SuVTVFf5uKt8A0127G9Is8 Message-ID: To: Sara Golemon Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Pre-draft for PipeOp v2 From: levim@php.net (Levi Morrison) On Tue, Sep 19, 2017 at 4:32 PM, Sara Golemon wrote: > I was planning to update the RFC, but wiki.php.net is having issues > atm and isn't coming back up with basic coaxing, so I'll just start > discussion informally, and the RFC can be updates later. > > Background: I made an RFC some time ago to implement HackLang's Pipe > Operator https://docs.hhvm.com/hack/operators/pipe-operator which > provides fluent calling for non-object interfaces. > I circulated it to mixed reviews, many negative, with the negativity > feeling like it centered on the use of a magic placeholder token `$$`. > > After discussion with Levi and others who suggested a simpler > approach, I'd like to offer > https://github.com/php/php-src/compare/master...sgolemon:pipe2 as an > alternate possibility. > > This version removes the $$ token, and instead treats the RHS of the > expression as a callable obeying the same rules as the callable > typehint elsewhere in the language. Specifically: > * Free functions as strings containing the function name. (e.g. 'funcname') > * Object methods as array($object, 'methodname') > * Static methods as array('Classname', 'methodname') > * Closure expression (e.g. function($x) { return ...; } ) > * Object instance with an __invoke() method. > > In a given pipe expression, the output of the LHS expression feeds a > single arg to the callable on the RHS. > Examples: > > $x = "hello" > |> 'strtoupper' > |> function($x) { return $x . " world"; }; > // $x === "HELLO world" > > Non-Goal: I didn't include support for base function names (e.g. > `"hello" |> strtoupper`) because of the conflict with constants. > Using a constant to store your function name is totes legit and > consistent with language syntax. > > Future Scope: Short Lambdas `$x => $x + 1` and Partial Functions > `someFunc('fixed val1', ..., 'fixed val2')` would help make this > functionality more useful and are worth discussing as a sub-thread, > but are not required to be implemented at the same time. > > -Sara > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php Thank you for making this proposal! As alluded to I had concerns on the original proposal and fully support this version. Sometimes simplicity is the mark of a good RFC and I think this is one of those times.