Re: PHP True Async RFC

From: Date: Wed, 05 Mar 2025 10:30:52 +0000
Subject: Re: PHP True Async RFC
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hello, Eugene!





What I think it could be.


async function baz(): int {
  $foo = foo();
  $bar = bar();


  return $foo + $bar;
}


// value is returned just like from any other ordinary function
$val = baz(); 




If we have code like $x + $y, and in one block it follows rule 1 while in another block it follows rule 2, this increases the complexity of the language. The worst part is that the same operators exhibit DIFFERENT behavior in different contexts. This violates semantic integrity. (A similar issue occurred in C++ with operator overloading, where a theoretically elegant solution turned out to be terrible in practice).

If you want to achieve a clean syntax for concurrency in PHP, I would suggest considering pipes in the long run.

For example:

|> $users = getUsers() ||| $orders = getOrders()
|> mergeByColumn($users, $orders, 'orders')

-- 

Ed.


Thread (110 messages)

« previous php.internals (#126575) next »