Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100726 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70977 invoked from network); 20 Sep 2017 17:37:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Sep 2017 17:37:45 -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.216.175 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.216.175 mail-qt0-f175.google.com Received: from [209.85.216.175] ([209.85.216.175:56680] helo=mail-qt0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 25/EA-62331-867A2C95 for ; Wed, 20 Sep 2017 13:37:44 -0400 Received: by mail-qt0-f175.google.com with SMTP id l25so3527443qtf.13 for ; Wed, 20 Sep 2017 10:37:44 -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:from:date:message-id :subject:to:cc; bh=o3DJwxL3Edv4RU6VlWmyGp9ffowiBAmaYbHzuRO2LxE=; b=Mx22mVVcpk18evzqEgJ72ChwPByQHfAo4Bgf4/iYtzZe91Zsw+BNsRAXZCFoy7ORJE yToF8eiCUI2iAkFfSibACUjCSCZY1nAiYWd/Nwf6XhjNZopnQQJvlPDj/ebAbZ8UXqAs vIT4tDS4XVBjP31VX0NkIOBW0acHpGuw2FvY9EHkn1+qXHzYTssgr1mJwWSptaJCfnZG ilk4DHXokTwgMkKjhCcjUaKeukLQpkvUkYZsrmlXzuc5cook0dxVBqB2tkSRnA+5JKVh pIFFw1h4EE0MPtgVUIU/El+MQhOKaKIRLEvjPubAhbSZLY2cLyTZSJluyfl17BxLb51m 5vQg== 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=o3DJwxL3Edv4RU6VlWmyGp9ffowiBAmaYbHzuRO2LxE=; b=Sc9xbYcDe1UaRX7XrnJzWoeM3cw3e8x0zaG3xDyningDzFbSp5zlPq5e27mOBCdpsW nYvJwloG6yjVXB1IiqUezZN44YEV+8wvT7RE0bWVa70tMepHENOujAmJiIRDqcDOp4Z8 uWNl3CJCme4fCy/s5n8IIDGrohWPdXf7aqrV1ah1niWuje8dzgEmha22W3G3pVzaicXi JUvpe/1n4dJNmXMeOUSdm0NckBoC/2c/9TBK8g8VNN9hSD++FBJqrvA5X9GZGZTxU4lq cSbt8Pm2yt/JRlhgYzriTLknq5evgrBC5kqaPFniUCkn0jh9/bO4tqo40yQ2Oydf6MxT g3uQ== X-Gm-Message-State: AHPjjUjBFXiNgkzCTua+gdrN+zP/hmjWMr2iCnRG4wwRVAYmKyE5dIJx WmY5TQJ3y7ANoOJX0TS/Dw252p+ddxpo9/LSRWtMvA== X-Google-Smtp-Source: AOwi7QC1E0mnp9vLEWinmdkKvPvwhAK0VXVutO9DwKkuPtg2Sdu+JfMwNtWf/JJGSkw9iNXiuOqoVRu/CEZnbky26n4= X-Received: by 10.200.40.146 with SMTP id i18mr8819743qti.94.1505929060822; Wed, 20 Sep 2017 10:37:40 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.12.132.3 with HTTP; Wed, 20 Sep 2017 10:37:40 -0700 (PDT) X-Originating-IP: [206.252.215.26] In-Reply-To: References: Date: Wed, 20 Sep 2017 13:37:40 -0400 X-Google-Sender-Auth: 6Y9lsPQmhyWwU-H6lPJnlVN0uW8 Message-ID: To: Derick Rethans Cc: Nikita Popov , PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Pre-draft for PipeOp v2 From: pollita@php.net (Sara Golemon) On Wed, Sep 20, 2017 at 12:52 PM, Derick Rethans wrote: > On Wed, 20 Sep 2017, Nikita Popov wrote: >> > 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. >> > >> >> I think this feature makes very little sense if it's not introduced >> together with a way of making partial application much more ergonomic than >> it is now. >> I generally agree with this statement, and it's why the original pipe-op (as with hacklang's version) included (a form of) pfa implicitly. If that means we should nail down the specifics of PFA and/or Short-Lambdas before even bothering to move into full draft of PipeOp, then that's fine. Levi made the very solid argument that they can be independently considered even if they compliment each other well, and given the triviality of the pipe half of that equation, I put it together first so that we have something to look at. On the topic of pipe2 specifically: The positive side of this diff is that it has zero impact on the backend compiler or opcache since it doesn't produce any new AST elements. On the minus side, the AST it produces opaques the original format. In practice, this hack is only visible if you're using your or my ast extensions, or if you use a failing assert. This is what I like the least about the approach I included in my link. It's not the first place we've hidden original intent behind AST transformations, but it's certainly the most visually jarring when serialized. > What do you mean here by "partial application"? > $trimX = trim($$, $x); In this example, trim isn't invoked immediately, instead, $trimX becomes a callable (closure) which takes a single argument and invokes trim() with that argument and the captured $x variable. We've "partially applied" some arguments to the trim() function, but we haven't finished forming a function call yet. Essentially, the above turns into this: $trimX = function($arg) use ($x) { return trim($arg, $x); }; The '$$' token used by HackLang's PipeOp works well enough because we know that RHS is only ever going to receive one argument (the result of LHS). A more generic approach to PFA would probably involve allowing for multiple positional arguments, perhaps like: $myInArray = in_array($2, $1); // Reverse the arg order, effectively PFA and ShortLambdas have the same scope capture issues however, which make them thornier issues to tackle. -Sara