Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130057 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 lists.php.net (Postfix) with ESMTPS id DA9E81A00BC for ; Sun, 8 Feb 2026 15:39:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1770565203; bh=WPgyMupxgZ1LF/4jC8X4kw8p47G+X96gagQyKYLS0o8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=P/C18TfauapfMuJBZWTZsC5Nes4WVttB6TdIX4EiHVWytl1SWmis6pPs58iGoGpFm 7ceaDKNzr5Wo+8WHGV/L8b/I6I+si0PCp7VYao4qJyRJSWPYWwMEOresUWnKpaYF3O ptK0uq5hG1Rl/UR6YkJ7qYUyIEJAMuNPBROVJ9MkuBX0t3X+ZAhHPTW8LeQ+qoLMtd IMl3NRvWQsHL5hw9k7k9RrRcLqeCIrZNvYvf4jY/rutInBDOu/KN4UYZ9aHx4mx/4L IoOOnzH9ugmB+n0GH9zRVBfIY5MjOfTjC+gDVmGbL+k0eGKRueOjnyBJ+8b+k2tJky KM2g88a8s8LPQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AA1F2180050 for ; Sun, 8 Feb 2026 15:40:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 ; Sun, 8 Feb 2026 15:40:02 +0000 (UTC) Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-383153e06d6so33478721fa.0 for ; Sun, 08 Feb 2026 07:39:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770565196; x=1771169996; darn=lists.php.net; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=M2XCMmaVMQWQ+i3Rc2CA0O8IHvNn3W+haw1NtR6W7rM=; b=mx6HnZHF0fBoLHN1jAb32RTi6zgrY8CHsB+bk2XjoWyGK6cT9LmdHRYYkhq4ihTkX8 gtJwJ4iW9gru6fGIJPoVaDF8usn7pysXJpWgBDjzTN60AMCpdZ9csN3DydBMCC31cwUg 5G+bQfj9QI3hVkXOhS0nq3gdTo283z+bXZ/KofsXf+KGkTRRQoLAz1s57wFONKIOmDMq Jhl3+102NLzWQgQWS4sEW3aPxUKgQ3w94HfIgU6F+3JC8YWbTmp5qcPC6vp5wmjilaEO LO3wDZ7nF8YkNpJpTFYd2qReEsijBRvBW72ppqXX3vGGkU9WjpkW6FCwzkHkr57P5OB2 bD0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770565196; x=1771169996; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=M2XCMmaVMQWQ+i3Rc2CA0O8IHvNn3W+haw1NtR6W7rM=; b=tOpuM1HjJHwyuecVFZXj8JBocGDa8/YRAOtgJrkaZgT5toE5oYjzL/FuOcnefCDp5j 4+XwcI6Z9XuJofp3pGur4nP7PVfN9dq+Puu6kRB1OwqBV3R1mBI20Rrn71kBq37bmOya sjRWpXtbCmbv+OFLvfDdGa8Yg7sC0i3XOGM/FmhOKsDtBTZUJAQiZXqcI/jvPGh6D8Jn XPVbKIJ6wY7g044pTvLILqsunocfZB4Gat67Vph5NtvjtQIBZEz9JzclPcC2QGp3Au2r CugplNvFB2sotEUH5QheVs4h4UWBGKgPSmY0JRFNqqLPoHob4mo5jj7kIxfbILsUWKvr SvJw== X-Gm-Message-State: AOJu0YyGU2jwnh6p+931z+kEU2yvXxv8iMtQjh8PPrplGx4Wh+cCNVJy /CLhMxkvUbgXHtUk2vGnwRJbXXFWVRrkVU7at04ZK1/F1DgZlYDzsyMd83vJBQ== X-Gm-Gg: AZuq6aKePHj0KluP6EpIHLISPpavwKLLduUYZWccl0Ztu5QXdgz2S0NB/lSQZj48xC6 hSSeqvVHCUhDazwaEK1JvIvWHKtKbdEqPG2qGcPaGwmdV6qv7E2lxNTC30wPqHOc3eP9Xb4FzfP KHusd2/ipZ/qyFMJAhTrT8aY7b2zuRpgGEcmd3UpwilC5y3qBxqKBgsZOj9Ji8GJcW3AlyPAUBv elszR2jCUHmEpBpRExnj+qnuTRbmma/Rd7PEaxfSHkQO+0C8zX+a/NbTrPuGs38NsfdzCF7oxBv AgaBFhn7wEglNMyEfIH4dE80qe8lH4CEpL0yeu9xsUGkyabANNpEiyXRkPwexeM3prCoZ3Q4Tq9 m6N1c6nFKH1vVRCWSEV3MBZj1qjebdaCCSQORy+vEnPpOjTmH8IUaIWUMohM2cya6CPBixfU0ON LSMZqwAxNJS9P5HwQC6F1urkk= X-Received: by 2002:a05:651c:54c:b0:383:1232:379a with SMTP id 38308e7fff4ca-386b4e9c52amr27945781fa.2.1770565195657; Sun, 08 Feb 2026 07:39:55 -0800 (PST) Received: from [192.168.1.16] ([46.181.226.137]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-386b6158615sm19244791fa.0.2026.02.08.07.39.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 Feb 2026 07:39:55 -0800 (PST) Content-Type: multipart/alternative; boundary="------------7yqQdVhGolJtelmcg0003Nco" Message-ID: Date: Sun, 8 Feb 2026 22:39:54 +0700 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Pipe to return To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: internals@lists.php.net References: <53c17181-caa4-41a3-b4ab-93069e6bb47b@gmail.com> <7351ad2ea062a074a94454257a241049@bastelstu.be> Content-Language: en-US In-Reply-To: <7351ad2ea062a074a94454257a241049@bastelstu.be> From: vadim.dvorovenko@gmail.com (Vadim Dvorovenko) This is a multi-part message in MIME format. --------------7yqQdVhGolJtelmcg0003Nco Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 03.02.2026 22:13, Tim Düsterhus: > That said, I agree with the others that I find the proposal a step > backwards in terms of readability. Having the `return` at the start of > the line is a clear indicator that the function ends there and it is > only a “single bit” of information I have to keep in mind while I > continue reading until I find the semicolon ending the statement. It > is also consistent with how assignments - the other primary use case > for pipes - start with the target variable and the equals before the > “pipe expression”. I think it would not be wrong to think of `return` > as “assigning to the return value”. Some time ago, I raised dicussion (https://news-web.php.net/php.internals/128141) of using pipes for assignment as well, you also took part in that discussion. Currently, i started with the RFC for `return` because it's simplest, to illustrate main cognitive problem. By the way, returning is something that can not be implemented function like assign_to. The main idea is that the pipe operator's main drawback is that it changes the usual reading direction. Function composition via + doesn't have this drawback. Maybe if function composition had been implemented earlier, the pipe operator wouldn't have been adopted. Now the pipe operator is part of the language, and I'm just trying to expand its use cases to write more intuitive and native-language-like code. Look, even simple statements like `return $x |> strlen(...);` may be confusing, if you were not familiar with the pipe operator before, because you do not understand, if you should stop after `return $x` or not. On the other side `$x |> strlen(...) |> return` is more intuitive in this way, even if you see |> for the first time, reading this line you understand, that it has two actions, defined by arrows, and it is some sort of data transfer. Even though you know `|>` is called a pipe operator, the `return $x |> strlen(...);` expression doesn't show how the data is flowing through the pipes. Something like `return strlen(...) <| $x` would be much more expressive in this sense. I had an idea to bring an RFC for the pipe operator to the left instead of this. But i chose not to invent a new operator, but simply to expand the grammatical possibilities of using an existing one. --------------7yqQdVhGolJtelmcg0003Nco Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
03.02.2026 22:13, Tim Düsterhus:
That said, I agree with the others that I find the proposal a step backwards in terms of readability. Having the `return` at the start of the line is a clear indicator that the function ends there and it is only a “single bit” of information I have to keep in mind while I continue reading until I find the semicolon ending the statement. It is also consistent with how assignments - the other primary use case for pipes - start with the target variable and the equals before the “pipe expression”. I think it would not be wrong to think of `return` as “assigning to the return value”. 

Some time ago, I raised dicussion (https://news-web.php.net/php.internals/128141) of using pipes for assignment as well, you also took part in that discussion. Currently, i started with the RFC for `return` because it's simplest, to illustrate main cognitive problem. By the way, returning is something that can not be implemented function like assign_to.

The main idea is that the pipe operator's main drawback is that it changes the usual reading direction. Function composition via + doesn't have this drawback. Maybe if function composition had been implemented earlier, the pipe operator wouldn't have been adopted. Now the pipe operator is part of the language, and I'm just trying to expand its use cases to write more intuitive and native-language-like code.

Look, even simple statements like `return $x |> strlen(...);` may be confusing, if you were not familiar with the pipe operator before, because you do not understand, if you should stop after `return $x` or not. On the other side `$x |> strlen(...) |> return` is more intuitive in this way, even if you see |> for the first time, reading this line you understand, that it has two actions, defined by arrows, and it is some sort of data transfer.

Even though you know `|>` is called a pipe operator, the `return $x |> strlen(...);` expression doesn't show how the data is flowing through the pipes. Something like `return strlen(...) <| $x` would be much more expressive in this sense. I had an idea to bring an RFC for the pipe operator to the left instead of this. But i chose not to invent a new operator, but simply to expand the grammatical possibilities of using an existing one.
--------------7yqQdVhGolJtelmcg0003Nco--