On Sat, Mar 8, 2025, at 09:24, Edmond Dantes wrote: > > > >for($i = 0; $i < 10; $i++) $results[] = async\async(fn($f) => > >file_get_contents($f), > > $file[$i]); > > // convert $results into futures somehow -- though actually doesn't look > > like it is > > possible. > > $results = async\awaitAll($results); > > > > `Future` can be obtained via `getFuture()`, according to the current RFC. > ```php > async\async(fn($f) => file_get_contents($f), $file[$i])->getFuture(); > ``` > And this semantics can be simplified to: > ```async file_get_contents($file[$i]);``` > or > ```spawn file_get_contents($file[$i]);``` > > From this perspective, I like that any function can be called with > `spawn/async` without worrying about its internals or modifying its code. The > pros and cons of this approach are well known.
Yes, that is much much nicer! It feel familiar to go: go file_get_contents($file[$i]) And yes, I realize that would be a fun error in go, but you get the gist. — Rob