>
>  This example highlights one of the concerns I have with fibers and this
approach in general. That example will still execute synchronously, taking
file_get_contents() * 3, even though it is in a coroutine function.
>

Is that really a problem? If a programmer wrote the code `$x = 1 / 0`, then
the issue is definitely not with the division operation.

> If you wanted to make it asynchronous, you'd have to do something like so:

Because this is more of an anti-example :) You shouldn't write code like
this. But if you really want to, at least do it like this:

```php
$x = await spawn fn => [spawn file_get_contents($a), spawn
file_get_contents($b), spawn file_get_contents($c)];
```

But this is also an anti-example because what's the point of writing the
same code three times when you can use a concurrent iterator?

```php
$x = await Async\map([$a, $b, $c], "file_get_contents");
```

(The functions will be included in another RFC)

Reply via email to