Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115194 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 33323 invoked from network); 28 Jun 2021 20:22:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Jun 2021 20:22:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 967C2180501 for ; Mon, 28 Jun 2021 13:42:34 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 ; Mon, 28 Jun 2021 13:42:34 -0700 (PDT) Received: by mail-lj1-f182.google.com with SMTP id k8so27667345lja.4 for ; Mon, 28 Jun 2021 13:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=eX/eB/fRY63n2RA0iOCyd3JEyKMTzRRL8B/KGhGK0os=; b=OBShabYSkGXc8hDBt3Uw2jPnCqCe7/HI0VakXMbgBVmVAtZRUQ9V6rpMaj65rQ2Kl4 y9gRCnJQjdtmFjsuZjlQFw5IDlN/a7qKJ6KAvJe3p1YHiqXXfOTBd5KopO8WSY1h9lH+ rpiOyz88ACQzPSLIPfTx/4VeaR9z0FOI7DBs8caq7zkc69/wJ5+XtnZHMkQCDdDlskA4 eGpqnIxm4/Evon8Rp6WVxc9zWnpdyEQqrdLmH8gMkVQjRjul+HHGH9pKyRLWcDeFLMkT BEOSBsWnWuoW/O1kH9sXPBn3TmqlVEw/BA1Pkn0O21UOM/5CfkPH/Eui7YZF1DypP44S 5xuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=eX/eB/fRY63n2RA0iOCyd3JEyKMTzRRL8B/KGhGK0os=; b=d0quVm3h7ouESo1uKHxjdZCjaNadrSehkFM8qXq2mVxhIQ/3onf9qiR/upj/8Dn5pg h5VMh7/FEBTdxUgY9iDYcyoAje235nDqCtPlYE1FnSgL15oG1QY4DFmIDZRsyGPQE18E apiCh8ntvIXPhlCfMt/8nDx22iUlTPHK7Umdql9rhGD8N+fAsg+0nfysmqw5vzCiaTv/ WtnUnvbol9m46tIdJv4HRkv8h7E/6agmZBQSTT6KtWlMebSZ4SCmJwXOiXFm8EoyXicV 8e+5k8DUnBEVluPmIqn0lNTeePB8wtUK9sWPNTb8B4oSFeGtSUMCTWcf07q63hyXox2s h9UA== X-Gm-Message-State: AOAM533R0+L2fVWwBS9QpOAVU/l3ZH+vzJn44R6sS9bRpLMp2RVCOQIC 9Y8B6k4uLVecqSpfzDuU1NhKiy19Vf/PPv/pNTlG8eWM X-Google-Smtp-Source: ABdhPJzWpx2/RKqpnUo31vrP6IKrsRZvUOj3M0CPIcqEeFND93beRY0oOakiU5VDRgUTDMUJsByBwlcRal+Tloqbh8U= X-Received: by 2002:a05:651c:b20:: with SMTP id b32mr984693ljr.288.1624912952146; Mon, 28 Jun 2021 13:42:32 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab3:7506:0:0:0:0:0 with HTTP; Mon, 28 Jun 2021 13:42:31 -0700 (PDT) In-Reply-To: <43d612c0-7462-463a-9536-ed5b66d9ae1e@www.fastmail.com> References: <43d612c0-7462-463a-9536-ed5b66d9ae1e@www.fastmail.com> Date: Mon, 28 Jun 2021 22:42:31 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Pipe Operator, take 2 From: olleharstedt@gmail.com (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) 2021-06-28 22:12 GMT+02:00, Larry Garfield : > On Mon, Jun 28, 2021, at 3:04 PM, Rowan Tommins wrote: >> On 28/06/2021 20:25, Olle H=C3=A4rstedt wrote: >> > Usage (ignoring the pesky undefined constant warnings ><): >> >> >> Unfortunately, you can't ignore those warnings; not least because >> they're fatal errors in PHP 8, as they frankly should have been in PHP 3= . >> >> You can use our current ugly callable syntax (strings and two-element >> arrays); you can tackle the complexity of unifying functions with >> constants, and methods with properties (as Levi explained in the other >> thread); or you can add a dedicated callable syntax, which the PFA >> proposal gets us with bells on. >> >> Regards, > > I think that's a pretty good summary. There's nothing that pipes or > partials do that you couldn't emulate in user-space today (really, since = 5.3 > is you really wanted to). The emulation is just butt-ugly and slower, wh= ich > is why most people don't do it except in very specific cases or if they h= ave > a user-space library available that makes it slightly less butt-ugly. > > The purpose of PFA and pipes (and short functions, and auto-capture > closures, and basically everything else I've been talking about all year)= is > to make those things prettier and as fast as reasonable, which makes usin= g > those techniques more natural. Once you start down that path, though, > there's really no usable solution before you get down as far as... PFA an= d > Pipes in their current form. > > --Larry Garfield The challenge is to write something that's pretty enough to be considered idiomatic. :) The pipe operator in OCaml is defined by one line: let (|>) v f =3D f v It wasn't always part of core, but eventually it was so common, it got included by default. Same could happen with a pipe() function in PHP, without the pipe operator, or that the function becomes so common, a new keyword is added instead: `pipe`. But it could probably not happen with a Pipe object requiring you to write ->pipe() at every step - it's too much ceremony and boilerplate. By the way, that's alternative 5) New keyword `pipe` to make the warning about constants shut up in a certain scope. Plus some other magic to allow nice chaining. ^^ Olle