Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100706 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92446 invoked from network); 19 Sep 2017 22:32:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Sep 2017 22:32:29 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.220.177 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.220.177 mail-qk0-f177.google.com Received: from [209.85.220.177] ([209.85.220.177:54228] helo=mail-qk0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 90/D1-62331-BFA91C95 for ; Tue, 19 Sep 2017 18:32:28 -0400 Received: by mail-qk0-f177.google.com with SMTP id t184so1087151qke.10 for ; Tue, 19 Sep 2017 15:32:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:from:date:message-id:subject:to; bh=/snarndOYw0B08mRRPqqV6CEWVCxLGk0e/ucifgwXJ8=; b=HLAAg/YA+tv2SmyWxjvDz3gEjIUim4MLad/SJ3j3qT4WjfDfrY3VQ+56HGurrZlSJT DbyhDgPm3kJG+FIGEZmaaG0pMLqQ8vRRJk8/I1dHXAmN5XuI82LcH6PZktkV7B25qr9x jYZM3/tmePNWTc4CuwXBnDshAIouEU/y41n3ATsefPvXMO9FIZGfOVaOEy3+DVh3X6Tu Lf5XiRDKqo7W+bzQ2yregt/yeOrknnLy6oGbWCfc3jn2CcwrWJK8lhvSsZ4D7FqnirYP nXiNAzPbddQYnxS/V2fuBn9hZ2w5Xmn8XVAFdyEyQsOCTQ5GTT3JxtNPuS/pvZrID5DT 4+hw== 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:from:date:message-id:subject :to; bh=/snarndOYw0B08mRRPqqV6CEWVCxLGk0e/ucifgwXJ8=; b=Lh1nRHhQm4CcBs11CodELmYYsev9wmbyQbUWJ/XxU4Nhoso0NsnNVGcTf6P68QmnJ5 tKBtZhb+3P6jGjSbz9nG65bOqFtutcmUG+kfKqtvz25oaiZ8TefFKg5eqe4Q4oAjtfku gFvONk1SkqEeOA+1Ss/ayLHrx5MpxUhyaTaBudBIowpM6bgqwxc11WBicHz6Qk1bt9qO AN6UGMxMnfzL33i0dqeZJl6Y2A25gsH2rDOc0WNnmgy7fNtytVmGixnx05BlNB7LfsQX lvaz4ZHL6AiuFhCJalENLxHqo2kNJOXAAIsLkGm6pRbVemraAbH2/p7GlILo+aqfzUcP Ej9A== X-Gm-Message-State: AHPjjUgoe3EJqtSEJvCxcs3GzfvwURzwcQnztpyuIEmsddS2CXOmICyq o+cP/JxNXbKjNc/oUZccP5gXc/FERVBS4+16IO58LVxvp9Q= X-Google-Smtp-Source: AOwi7QDYDewJsAu+SblgYBgqG1KliRcJVv0MYEAulxWncoRi34ajgBaIvy/bm3vLPIP6+5g5izFrvtBn8NhSL+szuU4= X-Received: by 10.55.123.1 with SMTP id w1mr4332221qkc.114.1505860345124; Tue, 19 Sep 2017 15:32:25 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.12.132.3 with HTTP; Tue, 19 Sep 2017 15:32:24 -0700 (PDT) X-Originating-IP: [206.252.215.26] Date: Tue, 19 Sep 2017 18:32:24 -0400 X-Google-Sender-Auth: 1ZKjaKa6W7tOHnQYSjRDpDPhCUk Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: [RFC] Pre-draft for PipeOp v2 From: pollita@php.net (Sara Golemon) 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