Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120841 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 67788 invoked from network); 18 Jul 2023 16:48:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Jul 2023 16:48:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F03791804C9 for ; Tue, 18 Jul 2023 09:48:51 -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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS29838 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 18 Jul 2023 09:48:51 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 6B2843200949; Tue, 18 Jul 2023 12:48:49 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Tue, 18 Jul 2023 12:48:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:cc:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1689698928; x=1689785328; bh=G2yo7Fkp5rxzHT4NkWTxI2LXJfsyitfxhAi hrfaIAYI=; b=BdR805o21zyazE/H/+BZKgofagohMr71jzzxwLXzLHBUXr/Wahh 3vUI3BP4H/5MDVNhleyGBqZ6Ofbuna4azPWs2YumCOvljKtupHtd9B7YqXvlxITf Ut0O/kViblknCL+fVaTf4gKTgKCjpxHbaXrN7fyMu5/ZFiZIp1T8fYNBeq8dSbeZ Kef3030A4acR/Y86uAhnThwSTGSe02HB2SlHTX5h8qIiHuRZuFpXD6kneOAcfnut OqoMHjVG075WvsgC9c2PakNU3bnSHcupqijtFw7zqTqABTZqHWIqLoR9mBtbRqM3 X/JmM3ND0tJ83o3aIv4b3MdqGJbydBWTRNg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1689698928; x=1689785328; bh=G2yo7Fkp5rxzH T4NkWTxI2LXJfsyitfxhAihrfaIAYI=; b=bkNB4SLCP9ZvYCoGA8/EpGERniMoR WtTPLi3xHCbzquiJJzYaVu5mizkQlH8O1c3B7i94TigQZTxbmOGFkjnSeEG7QQwu pcxTybgS3zy4LS2Tv/jbdqPwnKxpdVCfXTJro3DO7BIW9/ZZEEeSdDABNstRQzJV dmIuObdZYvQg67F1GDpPeXibXUxD7cy+bc+dMNuDqEoekmL5DO8qsJRQSCdAL2Qt EwWF3+RKiB9eGh4VW5GyHk1/5VQ+ivST5Jr+P98GyXp63AIvP1NFNF7lyT6csC44 KHVRwqPnKX6PnFTR8Y0rPyRXuGKNyjIaiPSAi9wDM5LpGe/5i702ma4mg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrgeeggddutdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepvdevteejtdefheevveegjeektdekgefgudfhudeh ieejfeetgffggeeghedvteevnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehg rghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id AB2D217000A0; Tue, 18 Jul 2023 12:48:48 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-531-gfdfa13a06d-fm-20230703.001-gfdfa13a0 Mime-Version: 1.0 Message-ID: In-Reply-To: References: <8055b366-32f1-4d2c-85d0-0cf665e6c8d3@app.fastmail.com> Date: Tue, 18 Jul 2023 16:48:27 +0000 To: "Karoly Negyesi" , =?UTF-8?Q?Olle_H=C3=A4rstedt?= Cc: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] pipes, scalar objects and on? From: larry@garfieldtech.com ("Larry Garfield") On Tue, Jul 18, 2023, at 4:41 PM, Karoly Negyesi wrote: > So. Let's get back to pipelines. > > I wrote this email because I was manipulating a robots meta tag string: > > $robots_array = explode(', ', $robots_string); > $robots_array = array_diff($robots_array, $remove); > $robots_string = implode(', ', $robots_array); > > Very pipeline-ish. > > You could write a userspace pipeline > https://gist.github.com/chx/6638aba76d8b414ffedc7e5af78fb479 but this has > the advantage of being spectacularly ugly and slow as well. > > Just converting it into a pipeline with > > $robots_string > |> fn ($x) => explode(', ', $x) > |> fn ($x) => array_diff($x, $remove) > |> fn ($x) => implode(', ', $x) > > has the same characteristics. What I would love to see: > > $robots_string > |> explode(', ', $) > |> array_diff($, $remove) > |> implode(', ', $) > > While that does look like partial function application, it does not need to > be. It could be just syntactic sugar. Namely, in the expression following > |> a $ is replaced by the entire expression before the |>. Step by step: > > explode(', ', $robots_string) > |> array_diff($, $remove) > |> implode(', ', $) > > array_diff(explode(', ', $robots_string), $remove) > |> implode(', ', $) > > implode(', ', array_diff(explode(', ', $robots_string), $remove)) > > We could use any other symbol but I liked the $ sign here because the > entire point is not needing a temporary variable between steps so the $ > sign stands for "unnamed temporary variable". I also believe it can't lead > to any ambiguous situation (famous last words). > > What do you think of this simple version? That's what Hack does, and what no other language does. I dislike it as it's actually much less flexible overall. It's also more work to implement. The original idea was that combining real PFA with a callable-based pipe would give us the same net effect if we wanted it, but with greater flexibility and more power across the whole language. Unfortunately the PFA RFC barely didn't pass, due to its complexity. A nicer implementation, if it could be found, would probably pass. --Larry Garfield