Re: [RFC] Pipe Operator (again)

From: Date: Wed, 26 Feb 2025 20:01:28 +0000
Subject: Re: [RFC] Pipe Operator (again)
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi

On 2/8/25 12:36, Tim Düsterhus wrote:
If the expression on the right side that produces a Closure has side effects (output, DB interaction, etc.), then the order in which those side effects happen may change with the different restructuring.
That is a good point. I see you added a precedence section, but this does not fully explain the order of operations in face of side-effects and more generally with regard to “short-circuiting” behavior. An OPcode dump would explain that. Specifically for:
      function foo()     { echo __FUNCTION__, PHP_EOL; return 1; }
      function bar()     { echo __FUNCTION__, PHP_EOL; return false; }
      function baz($in)  { echo __FUNCTION__, PHP_EOL; return $in; }
      function quux($in) { echo __FUNCTION__, PHP_EOL; return $in; }
      foo()
          |> (bar() ? baz(...) : quux(...))
          |> var_dump(...);
What will the output be?
This is unresolved. Best regards Tim Düsterhus

Thread (38 messages)

« previous php.internals (#126515) next »