Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120831 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93001 invoked from network); 17 Jul 2023 19:57:54 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Jul 2023 19:57:54 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9B11D180539 for ; Mon, 17 Jul 2023 12:57:53 -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: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (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 ; Mon, 17 Jul 2023 12:57:53 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id BF34C5C00AE; Mon, 17 Jul 2023 15:57:52 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Mon, 17 Jul 2023 15:57:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:cc:content-transfer-encoding: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=1689623872; x=1689710272; bh=v4pkrJh5TD 7+TZqKEY5zpz60YIb2IIVhcG14PMxQ9S0=; b=jMmBiOFLanpi2jPADbOtRP0Cir kf309X5rKVbISoRaJcncRLWMdQipz264j60KLyctNooVmXWAOROv1VAyTzvsTlTm ZRDE0PWSE2rzYV9CcNxNKKqpcoV4dGoa9bSXnzrJbjkc84EI6GzQ0WIMMaApqSwB 4pBP+sueCLk9j7UmW5AsGIlbj0CnbgsuHOhxU466T59MQSRzCvKCTN1Izzwfsj1k wYvTgov0Tzxb+O8iel/3SHRSGA5rpifO2D/PpDmixwEbPFi2TZBCDvEazR57XrMC AMq9xgnOYJsp+zWwtnLy6EXdiC+ZcOV9gnrLFL5qhtPawrGtUQKVXjyjO7Ww== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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= 1689623872; x=1689710272; bh=v4pkrJh5TD7+TZqKEY5zpz60YIb2IIVhcG1 4PMxQ9S0=; b=SkUx1b65Rc+yjEzktMCca440l7yQL7PdgA7R7Kz8OqTW89WlBER K+xFdeLwFVRuWzJbpGVaZ6fNY/7KZCPLdijhWpZQijIJrBJ9RwW+VUtWGmans9eP vA3O6lURb/kLb0mlViEPmq2VPfKqq+3y6sdjnyk5z+YqoNlk6lpUV5JpnIPVWPh3 fDLrqyb+T8Z/QF9lOBeKwMyN0rHcTN/4fD0eFClqcwpcagxAiZ7+BGvsz6Vr/XTE 4UDYonwCqth3Fg+zFZ/2SBqj39iqIvdmasSm4ote96GrdMq0qywLUq4h8S/GhqQW HmXkqV+YNa2fIsNBjq8d7E4U20rStt6zieg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrgedvgddugeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepfdfn rghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrd gtohhmqeenucggtffrrghtthgvrhhnpeffudduveeggefggeffudekheehheelvdejfffg vdekheduteejtedtuedtheehudenucffohhmrghinhepghhithhhuhgsrdgtohhmpdgvgi htvghrnhgrlhhsrdhiohenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 502AF1700089; Mon, 17 Jul 2023 15:57:52 -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: Mon, 17 Jul 2023 19:57:32 +0000 To: =?UTF-8?Q?Olle_H=C3=A4rstedt?= Cc: "Karoly Negyesi" , "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] pipes, scalar objects and on? From: larry@garfieldtech.com ("Larry Garfield") On Mon, Jul 17, 2023, at 7:07 PM, Olle H=C3=A4rstedt wrote: > 2023-07-17 18:58 GMT+02:00, Larry Garfield : >> On Mon, Jul 17, 2023, at 2:57 PM, Olle H=C3=A4rstedt wrote: >>> 2023-07-17 14:25 GMT+02:00, Karoly Negyesi : >>>> Hi, >>>> >>>> I tried to read on why the pipe RFC failed but by and large I also >>>> failed. >>>> >>>> The discussion on https://github.com/php/php-src/pull/7214 is very >>>> short. >>>> >>>> https://externals.io/message/114770 is not so short but it seems no= t to >>>> cover the latest version which uses first class functions? >>>> >>>> Could someone please give me a summary why it failed? I really would >>>> like >>>> to see it succeed :) I am writing code if not daily but certainly w= eekly >>>> that certainly looks like a pipeline. >>> >>> The pipe RFC was kinda forced in before a deadline, no? >>> >>> My own two cents: >>> >>> * It's trivial to implement a pipe() function or a Pipe class >>> * A Pipe class is better than both a function and built-in operator, >>> since it can be configured with custom behaviour, e.g. stop or throw >>> on empty payload, or repeat on a collection, or even with parallelism >>> or concurrency >>> * If I had voting rights, I'd vote in favor in a pipe operator :) >> >> From my recollection, there were a couple of things involved. >> >> 1. It was intended to pair with the PFA RFC, which didn't pass, which= made >> it a bit less compelling. >> 2. It was close to the RFC deadline, and it seems people get squeamish >> around that. >> 3. Some folks wanted Hack-style pipes instead of the pipes used by ev= ery >> other language with pipes. I've written before on why that's a worse >> design. >> 4. Arguments that it can be done in user space, which is not true, as= I have >> a user-space implementation and it's comparatively cumbersome and def= initely >> slower than a native operator would be. >> 5. General "meh" attitude on FP features in general from some people. >> >> Side note to Olle: If you want a customizable pipe, you've just descr= ibed a >> Monad. :-) It's literally "contextually-sensitive func concatenation= ." A >> monadic bind operator would be harder to do with PHP's weaker type sy= stem, >> but there are ways it could be done. > > Mm I don't really agree with that, I think monads make sense only in > languages which support them syntactically. A Pipe class is a very > straight-forward construction, and the blog posts I've read about > monads in PHP don't look pretty at all; lots of syntactic noise going > on. But that's another discussion... :) At its most basic: class Foo { public function __construct(public readonly mixed $val) {} public __bind(callable $c) { return $c($this->val); } } new Foo('beep') >>=3D func(...); Where >>=3D is the operator that translates to "Call __bind() on the LHS= object with the callable on the RHS." Poof, we now have a monad operat= or. This one is effectively the same as |> as it doesn't do anything, b= ut you can do whatever you want in the __bind() method. =20 But that's a separate operation from |> or func concat. (Unless we want= ed to implement it as an operator override for |> that an object can do,= which... is an option. I don't know if I like that option, but is an o= ption.) The implementation for all of this is fairly trivial. It's agreeing to = do it that is the challenge. --Larry Garfield