Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114780 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 19054 invoked from network); 8 Jun 2021 10:27:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Jun 2021 10:27:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BB9261804C9 for ; Tue, 8 Jun 2021 03:41:55 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,URIBL_SBL, URIBL_SBL_A autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 8 Jun 2021 03:41:55 -0700 (PDT) Received: by mail-lj1-f174.google.com with SMTP id c11so26372003ljd.6 for ; Tue, 08 Jun 2021 03:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YHXvg0HaipxlIGJdrW3FWLmzFNSpRxuK35X6ef4VFeE=; b=UlTeNXVYm/ZMmag32zWB+vDJ5xF/WzpEoA50PkIC++YlgtwseUaQ+FbWEOI6sGQTyt +CUK3OgiAp4ZsG6gF9MgrqCxrJDmAGuiyYg9zSNctL/Xt8iaZVzgPF+VYR9UnAxTMQah 87C42jZWaCibpgVrJfuy7yOLDiNPfLicrpiXZTWYrgFV+H9w0b1nZUaLOKZ2wP0e1sFG ACGB/eX3Tu6uhth6P20hLMbWpsSbitG32cX4EQYmmdXz2Ovq1wcxeluJ5MMNIE9DSq/6 tWegcqXK0Do0M+Uk5me9i8Ai5PXVQNzPyNFKQMuTLj4UQlT7qiv7sqzZY/rVg2tCbu6a 5g7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YHXvg0HaipxlIGJdrW3FWLmzFNSpRxuK35X6ef4VFeE=; b=aAb8Gd8tjHfe03R71tGyaxuaoUBxEaiamsnME9YazOFUucBxqfgM/y3iF0lUKlIgCg dwgPpqY+Ak4dtwZeagSvS0JJWhvARF5/J1VfYNwT6Z8+KaeGu2y/3B0TYUEdPJWCPwFv /Y74v3jK4W2eJEeduaO02EV/jX+cBJwrWspW6/OOHqPKK97f1+whmfWVaNBQyubXhrq4 6wC1Xk2BbVUcbFrXadQma6aiCdwceJ0d2Cf74gBRH7gQBKMqEQIMbJPCUaNlGgTHgb32 fdHqWpiUNsrdJaAKnCRxsK4DMBxsHLU7YxHlwIwTeRPSC4UH8oYAy4ZBAHuVsfWPobzE M5Cw== X-Gm-Message-State: AOAM5320qWQ3Z4iLy8TJ7zxYVvQk56oNCE7qBt45tFsVGUTTztSyzLGv D55xFfZNqQvXHthw1+fziL7qtYVDULK/z+EUQw== X-Google-Smtp-Source: ABdhPJwlMbfCPgHSy/MByTgLoK7p9Ig36uu8CVkW9GTrBCZ0cklZ4IFJl7A/0zih/w50H8ZqBrPMO28HWvBOVcpgKio= X-Received: by 2002:a2e:8557:: with SMTP id u23mr10114347ljj.472.1623148910223; Tue, 08 Jun 2021 03:41:50 -0700 (PDT) MIME-Version: 1.0 References: <13daea98-c32e-491b-a37c-3e151dd1f6c2@www.fastmail.com> In-Reply-To: <13daea98-c32e-491b-a37c-3e151dd1f6c2@www.fastmail.com> Date: Tue, 8 Jun 2021 12:41:38 +0200 Message-ID: To: Larry Garfield Cc: php internals , Nikita Popov Content-Type: multipart/alternative; boundary="00000000000036262705c43ece99" Subject: Re: [PHP-DEV] [RFC] Pipe Operator, take 2 From: guilliam.xavier@gmail.com (Guilliam Xavier) --00000000000036262705c43ece99 Content-Type: text/plain; charset="UTF-8" Hi, On Tue, Jun 8, 2021 at 12:09 AM Larry Garfield wrote: > On Mon, Jun 7, 2021, at 4:00 PM, Eugene Leonovich wrote: > > On Mon, Jun 7, 2021 at 9:03 PM Larry Garfield > > wrote: > > > > > https://wiki.php.net/rfc/pipe-operator-v2 > > > > > FTR, there are several typos in the "Hello World" examples > (*strto*t*upper, > > htmlent*i*ties*). Also, these examples will not work as written because > > explode() expects two arguments and will fail if you pass only one: > > https://3v4l.org/tLO0s. > > Hm. You're right. It used to, but it's been a very long time since > explode() allowed an empty split, apparently. I updated the example to use > str_split, which is what I'd intended to do in this case. Thanks. > Are you thinking to implode()? Anyway, you forgot to update one `explode(?)` to `str_split(?)`, and also, the first `fn($v) => 'strtoupper'` should be just `'strtoupper'`. About Haskell, rather than (or in addition to) the function composition [not "concatenation"] (.), I would mention the reverse application operator (&): https://hackage.haskell.org/package/base-4.15.0.0/docs/Data-Function.html#v:-38- One thing I note is that even with PFA, some examples still need an arrow function, e.g. the PSR-7 one: ``` ServerRequest::fromGlobals() |> authenticate(?) |> $router->resolveAction(?) |> fn($request) => $request->getAttribute('action')($request) /* ... */; ``` while in Hack you would write it as: ``` ServerRequest::fromGlobals() |> authenticate($$) |> $router->resolveAction($$) |> $$->getAttribute('action')($$) /* ... */; ``` Also, quoting from https://wiki.php.net/rfc/first_class_callable_syntax#partial_function_application : """ Both approaches to the pipe operator have their advantages. The $$ based variant allows using more than plain function calls in each pipeline step (e.g. you could have $$->getName() as a step, something not possible with PFA), and is also trivially free. A PFA-based optimization would entail significant overhead relative to simple function calls, unless special optimization for the pipe operator usage is introduced (which may not be possible, depending on precise semantics). """ Could you (or Nikita) expand a bit on this (esp. the advantages of the PFA approach / disadvantages of Hack's approach)? Regards, -- Guilliam Xavier --00000000000036262705c43ece99--