Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126335 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 29EED1A00BC for ; Fri, 7 Feb 2025 15:15:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738941162; bh=CSUjZLwVU3Jc4/IhK4YaE4MD8BK/nLpXv8cYFVxPT4s=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=JJkXic50CkqwuSH+WGtnrxzbrtzA2/E6PWm6enfBqkL8xfCLkmrkEnpSsQfe9Vre0 y7lv6cehAYv7HQu8C5HYzQgBC8pODEc5meNDUMnrSh3MuBJoi749jQ1oKmU7RiPcFl jNGERUfeBPyLaf9CMBLeEAmI+n33dWSXqpG/Z9a1cDEvsl9Y4ozWvkR5T3DqOdxVp1 53Nk3RtCQKd0YraAFWPIXoquNIF7C7IS1Yu7ev+IpSsg0ofWr02QxXAxGUYqi3Dudo n7KreRdOaw+fh7QoH0Pi5lephiuA3Sgv6cQOP+nHGHK0Wk3Bg8bcZfV3NgtfRfLArp SZZQ8KTNqrLVQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id ABF331805A2 for ; Fri, 7 Feb 2025 15:12:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_PDS_PRO_TLD autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from crimson.ash.relay.mailchannels.net (crimson.ash.relay.mailchannels.net [23.83.222.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 7 Feb 2025 15:12:40 +0000 (UTC) X-Sender-Id: yszpovajlk|x-authuser|juris@glaive.pro Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 7F2E090405C; Fri, 7 Feb 2025 15:15:23 +0000 (UTC) Received: from server42.areait.lv (100-122-220-145.trex-nlb.outbound.svc.cluster.local [100.122.220.145]) (Authenticated sender: yszpovajlk) by relay.mailchannels.net (Postfix) with ESMTPA id AC070903F4F; Fri, 7 Feb 2025 15:15:22 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1738941323; a=rsa-sha256; cv=none; b=H1sn3NiUrNDot0+zNcZG6ujWY+5Zn6zcyOgOseD13/54BjP2btwjCeFutRa0/ac/pAc0l6 DX0AbdIzxy9LIFwszonpsGvE+WC3ZWfrMUXtoQrL7Be2IS7YmMNSpQwTn8y4v5Vpcc1wpf yWW+CmsGmrUPKMHnx5cUNhgIXpXd9/3PGg+BlKrc8g49g0kVLrrtI3IvAnR3XhGAHAYn8f Ay4rLcaCgTZ1mz61r4R7GimjjrjbSG3kL7MrOhfOOdVIXwTsHR12Fb6bYql/84iQ2NG3+a xhd8iNKDm8de0P0C4NEmkyOCgcqHJrR18TEOeti4AK9EuNlvsPrN7JVCMBYMYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1738941323; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VWKosRjJ5hS+uNUy2ikz0+6sdwdiUyU8xtUDU7HFy6c=; b=ZlXG814TrduyQYasGWyuJo1AGU2Fbc++uGL1hPhfO+q1oJtzGKuvejeSbzBvhHKD8xgBOR /IFyETZ4PgzcF7zN0GMXfDLMUPb+EOD9RHZen/UCLDyqd6IMneajafGLwzBh6XMCtGdaIb 3v8chT+uJlBUnonEG0hDd+L3LYe4apDWdtMD8604Cl8EMVikvlwYy/v92d+aLN1EQ2Lmoz ejOL3D9v+sl1bPeyQgat0KZpKwJPguN+V3Qq208/jdu0qfqN8msZx+c1fy3aS7FvDiGzaR Nl3HDPzE1zmM3y+j46sC/U35diAOVTs1Xlo4PI+K+zto0Y5CYIzKp4ePhRM4aA== ARC-Authentication-Results: i=1; rspamd-57688b6496-78qtq; auth=pass smtp.auth=yszpovajlk smtp.mailfrom=juris@glaive.pro X-Sender-Id: yszpovajlk|x-authuser|juris@glaive.pro X-MC-Relay: Neutral X-MailChannels-SenderId: yszpovajlk|x-authuser|juris@glaive.pro X-MailChannels-Auth-Id: yszpovajlk X-Dime-Whispering: 5b8286bf7ad70b87_1738941323380_438119360 X-MC-Loop-Signature: 1738941323380:3660932095 X-MC-Ingress-Time: 1738941323380 Received: from server42.areait.lv (server42.areait.lv [212.7.207.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.122.220.145 (trex/7.0.2); Fri, 07 Feb 2025 15:15:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=glaive.pro; s=default; h=Content-Transfer-Encoding:Content-Type:Message-ID:References: In-Reply-To:Subject:Cc:To:From:Date:MIME-Version:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=VWKosRjJ5hS+uNUy2ikz0+6sdwdiUyU8xtUDU7HFy6c=; b=mSrXPj2SpBFt9WOLVFhEJdwd0W IWFpq6eVEquZajP1qXcMtJeUYVExHeVE3nQVl7fb66HWrapMm+NHbZNKFxstFrDxJ5YFeGWvZeVsG R5xzHhNCAbOnCBi7AXBWagu6pbUtXUvJC94uyuRKDIOsR6jx49C0BJLfw+HGiiAas3mYZAUDcXSYv HEKkXBQ+DOF+dFP9bnZr/O8JKJb3yYsP9Bj5aV9SCEIvj4YO7Qyhsqhnoh6d6P5RHlyiGPYMV//DV rAP+yievfRn6nfdDDHXqWm0tB7t6tQg1nH3rlKisn9jeFvjqeislJfsICFM3kgaG6ONAyM/zCwT75 sLytC/0Q==; Received: from [::1] (port=58120 helo=glaive.pro) by server42.areait.lv with esmtpa (Exim 4.96.2) (envelope-from ) id 1tgQ4d-00F648-39; Fri, 07 Feb 2025 17:15:20 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 07 Feb 2025 17:15:19 +0200 To: Larry Garfield Cc: php internals Subject: Re: [PHP-DEV] [RFC] Pipe Operator (again) In-Reply-To: References: User-Agent: Roundcube Webmail/1.4.8 Message-ID: <17d2962d351ee181ec05fb45544accd4@glaive.pro> X-Sender: juris@glaive.pro Organization: SIA "Glaive.pro" Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-AuthUser: juris@glaive.pro From: juris@glaive.pro (Juris Evertovskis) On 2025-02-07 06:57, Larry Garfield wrote: > Hi folks. A few years ago I posted an RFC for a pipe operator, as seen > in > many other languages. At the time it didn't pass, in no small part > because the implementation was a bit shaky and it was right before > freeze. > Nonetheless, there are now even more (bad) user-space implementations > in > the wild, as it gets brought up frequently in "what do you want in > PHP?" > threads (though nowhere near generics or better async, of course), so > it > seems clear there is demand in the market for it. > > It is now back with a better implementation (many thanks to Ilija for > his > help and guidance in that), and it's nowhere close to freeze, so here > we > go again: > > https://wiki.php.net/rfc/pipe-operator-v3 > > Of particular note, since the last RFC I have concluded that a compose > operator is a necessary complement to a pipe operator. However, it's > also > going to be notably more work, and the two operators don't actually > interact at all at the code level, so since people keep saying "Small > RFCs!", here's a small RFC. :-) Great feature! Three questions and a comment from me. 1. Do you think it would be hard to add some shorthand for `|> $condition ? $callable : fn($😐) => $😐`? 2. Is compose in the scope or not? You mention it in both the main RFC body and the future scope. Or are those different composes? 3. Does the implementation actually turn `1 |> f(...) |> g(...)` into `$π = f(1); g($π)`? Is `g(f(1))` not performanter? Or is the engine clever enough with the var reuse anyways? I don't think Laravel's pipeline is relevant here. In it each callback is responsible for invoking the rest of the chain. Thus it allows early returns and interacting with the return value of the following chain (`return 5 + $next($v)`). More like a middleware chaining tool, not a pipe in the same meaning as in this RFC. BR, Juris