Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129970 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 9E94A1A00BC for ; Sun, 1 Feb 2026 06:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1769926677; bh=221qcvjO88hnvGqPQ+q7O3wNrwjGwfv4gKVTJteabO8=; h=Date:Subject:To:References:From:In-Reply-To:From; b=h5AsMefLJCwSzOa/br/rUGOHCMGrE/2uuLzIhs6mteztfjfjYdXVx01keT0uABZPC HaaF/c2Yo4RStLM/8KY5JlAFBWY4HW+OqQITFWft9AyvA0pMfixCHw0bzsjsOcmGYm 7x4inPa4lWsFV+kIhcBIL1uWR/1YzYkGTc24cFASDHo8y6qDxqbeCclFnhT8Z0nmdx FQB1CJyV1+slBWzE7bxFtbqezXgCQhsHSM6Y6xPg2KDu+1+8OtnSvLQc85sPXiSw0y h7HYPW/iPngoIogMCOS9A6TpS6FTkg8UVem56ouMX/aEQ5Q2kGplfNtnAmfzU70r6O rMNp/q5MEsv/A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 58D7D180042 for ; Sun, 1 Feb 2026 06:17:56 +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-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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, 1 Feb 2026 06:17:56 +0000 (UTC) Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-59de0b7c28aso4005373e87.1 for ; Sat, 31 Jan 2026 22:17:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769926670; x=1770531470; darn=lists.php.net; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=432p64e+KQCHJiT+cO/M/7wjqOf6MsokzD3HzwAh51o=; b=eUUqdNmS0GOoqCMDg3p4rfRrK8cGZF9ry4YXEFkm9+WA6sgWAriIdPBnRoZQqq0Kv+ l67iLm4A3iInE0X+2HgaYHTNjm7CBKHaiTl3Eko2Z31cmp8SbOXP5NnJykphHSakLw1N eaOAKUo1C4PzPMG4FchfGCG1Ae75MeyMyiX/oLn0ncd+MRbot3GzaeEoYb/ZBQSH8brW +/NtbHh2pSqKoyEnwA5gRmbjieM6zNbMxbJjsyz4zoHQfoKbOjLz9oovvYVZVj3FS7X4 MFI1k5gg48Lv4cmr2U84wiLFxeXsfWgeQyDPyKd+HoWrptHjYVLsFjGRVtXcNvfQnWXo 5qUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769926670; x=1770531470; h=in-reply-to:from:content-language:references: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=432p64e+KQCHJiT+cO/M/7wjqOf6MsokzD3HzwAh51o=; b=ouuWBz4Beu6g/oEpOll87/9yac3KQqBeFkB58Mbvcfv6W5Y3sqRk8RTA4ttvMtDhTO tHyTyuJAOHr02mMt/YwqIutlFG29qaZNzb97wVrJgEq4yKYUUMsq51uh0aWE//kupuUG zbWx1Jhj6h+9ZTY+c/5QZB7NAC0hElPL3AgrcrdikdU5vhqYADfoJsoSZIK6QWOJOffB x6HjWlrH8Mvf80mtUe8D7N3D5CuECSdaQg2BnWsZzVWakSo+CF11SVwurOe/yWjdeKH8 qXpQA7RxIltQkJYEoscITUN7ZTFAz4dIoJmO+tOPEsl0+y5yh0b+L5oI5iRUUvSbSACq /v7Q== X-Forwarded-Encrypted: i=1; AJvYcCWvijp0rVWt1WWE0A2WpzXCd8UQrC561dFlC7nuhICDSwYMP2BQ/VC2axUrTX9QJaWTfHNI7ewa4Yw=@lists.php.net X-Gm-Message-State: AOJu0Yxt8LIwP2y6CqzxkFOBMQtS5bT3OMh6T3z8LSRpDTnqLTvv4fo3 eke0d/RUAYOFciR6KVyIgAWlsPVUuR2ErNIbcXFqSGvL/EK/UpFG7AN/ X-Gm-Gg: AZuq6aISBvslSwgFoslQA9QQkO8JL7EXTNYGVw/bdMDsRgxWgbdE25YJzsvzuhOlXzt nMF/iFWTa5dQ6C8n3gfB3YXBkTJT9dcQ/Z2BVDvQ1z5vwUhN+D7JvRmlxMDamLwvkA9Ytkn1ACd oNB0xOxA9pQikXv2r8UUl61BbaDLVaFb7JqpQs4xj+JDToKWsnjmQ//YqDHMW9Q7D+IiDxcVNRo 9l1LVlEW8sxd87pJC+2T8ATe+HkNkQAhjtRHf6J5GM7a9jIAmHU0bDLkyBvAxtBZLkVX8yBjOb+ THqVqvr9kz+BI8PMHQk41RmsFBDoZACaN1SCoX6DaLVBqhmPySX/CbLAZnicuoXTbbRhNJPaSrE aCCPsTnXyCNMO+7KFZ/jhtjO3IbM3RZcolq7BJrY9k1AT8on59lteK30jCpcYkNQzJe+ML4hc X-Received: by 2002:a05:6512:3c83:b0:59e:525:361e with SMTP id 2adb3069b0e04-59e1642bbccmr2876734e87.41.1769926669254; Sat, 31 Jan 2026 22:17:49 -0800 (PST) Received: from [192.168.1.16] ([46.181.226.137]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-59e074b98ebsm2773607e87.80.2026.01.31.22.17.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Jan 2026 22:17:49 -0800 (PST) Content-Type: multipart/alternative; boundary="------------jKiqhm5wPtHUmgfUBAu3aOkg" Message-ID: Date: Sun, 1 Feb 2026 13:17:48 +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: Jordi Kroon , internals@lists.php.net References: <53c17181-caa4-41a3-b4ab-93069e6bb47b@gmail.com> <019b55a4-8d06-4d88-801e-c3c2de597f1c@Spark> Content-Language: ru In-Reply-To: <019b55a4-8d06-4d88-801e-c3c2de597f1c@Spark> From: vadim.dvorovenko@gmail.com (Vadim Dvorovenko) This is a multi-part message in MIME format. --------------jKiqhm5wPtHUmgfUBAu3aOkg Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Jordi Kroon: > I like the general direction and I am not fully against the idea. That > said, I am hesitant to introduce another way to express the same > thing, especially when it affects readability. When we are speaking about pipe operator, it all looks as trying to introduce another way to express the same thing, and it affects readability. As for me,   $temp = "Hello World";   $temp = htmlentities($temp);   $temp = str_split($temp);   $temp = array_map(strtoupper(...), $temp);   return $temp; and   return array_map(strtoupper(...), str_split(htmlentities("Hello World"))); were quite effective ways of expressing value transformation flow. But that RFC was adopted. My RFC is an attempt to quickly eliminate the cognitive side effects arisen by adding the pipe operator to the language. The addition of the pipe operator didn't immediately force all language users to use it. But it did give them the option. Which method of expression of same thing sould be used in different cases, most likely will be described later in the coding standards of specific projects. Likewise, the method proposed here will not be mandatory for use, but there may be cases where it will be chosen for greater readability. > More importantly, I do not think the responsibility for returning > should live inside the pipe. Returning is control flow, while the > pipe’s core purpose is transforming data. With this change, the pipe > no longer clearly communicates “transform this value,” but can instead > become responsible for ending execution. I would rather see the pipe > produce a result, and keep the return outside the pipe so the intent > stays explicit. > > Also, while the example below obviously would not work, it highlights > the potential ambiguity this introduces. In a long pipeline, it > becomes less clear where returning happens and what role the pipe is > playing. > > function giveMeFourtyTwo() { > return 42 > |> return; > } > Also if you put this into the short `fn` syntax. It will break for the > same reasons as above. > > fn () => 'hello world' > |> strlen(...) > |> return; Our language is now very flexible. But such flexibility would be impossible if everithing was strictly divided into categories. Take the `throw`, for example. It's obviously intended for flow control. However, it can be used anywhere, like in following example. return 42 |> fn($val) => throw new RuntimeException($val); // or throw throw throw new Exception(); Although such a statements contains ambiguity between return and throw, or between multiple throws, we don't criticize the language for this possibility. In such cases, we say the author of the code has chosen an unfortunate style of expression. My proposal, on the contrary, does not allow using two types of return in one expression or using return inside an arrow function. In this sense, my proposal is quite strict. You can use either way of expression, but not both at the same time. Thus, ambiguity is generated not by the programming language itself and its capabilities, but by those who express their thoughts in it. We should not limit the expressive instruments of a language simply out of fear that they will be misused. -- Vadim Dvorovenko --------------jKiqhm5wPtHUmgfUBAu3aOkg Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Jordi Kroon:
I like the general direction and I am not fully against the idea. That said, I am hesitant to introduce another way to express the same thing, especially when it affects readability.

When we are speaking about pipe operator, it all looks as trying to introduce another way to express the same thing, and it affects readability.

As for me,

  $temp = "Hello World";
  $temp = htmlentities($temp);
  $temp = str_split($temp);
  $temp = array_map(strtoupper(...), $temp);
  return $temp;

and 

  return array_map(strtoupper(...), str_split(htmlentities("Hello World")));

were quite effective ways of expressing value transformation flow. But that RFC was adopted. My RFC is an attempt to quickly eliminate the cognitive side effects arisen by adding the pipe operator to the language.

The addition of the pipe operator didn't immediately force all language users to use it. But it did give them the option. Which method of expression of same thing sould be used in different cases, most likely will be described later in the coding standards of specific projects. Likewise, the method proposed here will not be mandatory for use, but there may be cases where it will be chosen for greater readability.

More importantly, I do not think the responsibility for returning should live inside the pipe. Returning is control flow, while the pipe’s core purpose is transforming data. With this change, the pipe no longer clearly communicates “transform this value,” but can instead become responsible for ending execution. I would rather see the pipe produce a result, and keep the return outside the pipe so the intent stays explicit.

Also, while the example below obviously would not work, it highlights the potential ambiguity this introduces. In a long pipeline, it becomes less clear where returning happens and what role the pipe is playing.

function giveMeFourtyTwo() {
    return 42  
        |> return;
}
Also if you put this into the short `fn` syntax. It will break for the same reasons as above.

fn () => 'hello world'  
        |> strlen(...)  
        |> return;

Our language is now very flexible. But such flexibility would be impossible if everithing was strictly divided into categories. Take the `throw`, for example. It's obviously intended for flow control. However, it can be used anywhere, like in following example.

  return 42 |> fn($val) => throw new RuntimeException($val);
  // or
  throw throw throw new Exception();

Although such a statements contains ambiguity between return and throw, or between multiple throws, we don't criticize the language for this possibility. In such cases, we say the author of the code has chosen an unfortunate style of expression. 

My proposal, on the contrary, does not allow using two types of return in one expression or using return inside an arrow function. In this sense, my proposal is quite strict. 
You can use either way of expression, but not both at the same time.

Thus, ambiguity is generated not by the programming language itself and its capabilities, but by those who express their thoughts in it. We should not limit the expressive instruments of a language simply out of fear that they will be misused.


--

Vadim Dvorovenko

--------------jKiqhm5wPtHUmgfUBAu3aOkg--