Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115456 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 38810 invoked from network); 17 Jul 2021 15:35:45 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Jul 2021 15:35:45 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 115421804AA for ; Sat, 17 Jul 2021 09:00:15 -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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (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 ; Sat, 17 Jul 2021 09:00:14 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 24EDB5C00E7 for ; Sat, 17 Jul 2021 12:00:13 -0400 (EDT) Received: from imap43 ([10.202.2.93]) by compute1.internal (MEProxy); Sat, 17 Jul 2021 12:00:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=ACvTtJ CfLbhN79IAcFj9ps6mHFiWkCLgBAZQ9F9kR2w=; b=stUbn2gblQfy4d6ljcUC8F e2RAdRzSSo1cRo4KPOPbxhdKKkP1fesgsHeuO6yX7XgIgqLec+ISxpMSo0t9iiYD gy3wAZXfWkjvX5mjvb8jjdd1gJaWJXffAVJ/idZVDwtPMFzbk4WWdjCe/7uBN6AG JPnF9IkfiMPgj418VkNSmEEXm+/yDoYVQlRje0nPE2414tfuLKdt73uWvtTJ8GvI kyxxj5LpoiLjJsDcdK1QPrF8JBmFSQK3PqwWz+ACTXqK61uoUpCH9hMPujwmB/OT eMMSPKr7tKOB7IjOC6BTi1wNmeIzwrGPZ/emxBI5bUudUXTq9qJDP3IX3lvBoYyQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvdehgdegkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnhepkeetleehffegfedvudefueejkefhvddtueeuvdevteei veehledugeejudfhhfetnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghr fhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id E8056AC0977; Sat, 17 Jul 2021 12:00:12 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-533-gf73e617b8a-fm-20210712.002-gf73e617b Mime-Version: 1.0 Message-ID: <83bdd8d9-9962-4995-9aff-4bd9b6b7e9b9@www.fastmail.com> In-Reply-To: References: <6a2ef792-9624-4355-ad08-dcc7bfa5e19f@www.fastmail.com> Date: Sat, 17 Jul 2021 10:59:52 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [Vote] Pipe operator v2 From: larry@garfieldtech.com ("Larry Garfield") On Sat, Jul 17, 2021, at 9:48 AM, Marco Pivetta wrote: > Hey Larry, > > I just voted "NO" on this: it took me a long time to decide, because I've > been vouching for pipe-alike operators myself for a while. > > The reason why I voted "no" is that this is feasible with a `pipe(callable > $first, callable ...$piped)` function, without having to add syntax/AST for > it. > > Type safety for such a closure would still be very messy, but feasible with > some macro-based templating of docblocks. > > The simplistic approach to this is simple composition (the `.` you > mentioned): > > ```php > /** > * @template TIn of mixed > * @template TOut of mixed > * > * @param callable(TIn): TIntermediate $first > * @param callable(TIntermediate): TOut $piped > * > * @return callable(TIn): TOut > * @return TOut > */ > function pipe(callable $first, callable $piped): callable > { > } > ``` > > Pol Dellaiera (https://github.com/drupol) has done a lot of work around > this stuff, specifically the type inference bit, in > https://github.com/loophp/combinator , so I see hope to get better types at > a later stage. > > Therefore: > > * userland runtime **implementation** is trivial > * userland type-safe definition is non-trivial, but not insurmountable > > > Marco Pivetta Hi Marco. Thank you for your explanation, even if I naturally disagree. Out of curiosity, what sort of additional power/capability/flexibility/etc. would, in your mind, justify pipe or similar being a native feature? PHP has a *ton* of native features that *could* be done in user space, or are simply syntax sugar, but still wildly popular and useful as native syntax. What is your heuristic for that? (The fact that there are 3-4 user space implementations of pipe-like behavior, all incompatible, is one of the reasons why I think standardizing it into a common core syntax *is* a good idea, though I know others disagree.) --Larry Garfield