Are value-consuming generators useful?
- Dominant language
- C++
- Stars
- 347
- Forks
- 47
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 1
Description
The two-argument variant of `async::generator`, one that is able to consume values from the resumer, seems to have no practical use case. At least none has been provided in the docs or examples. I personally question its utility because of the shape of the interface. The coroutine sees it this way:
```
auto value_from_resumer = co_yield value_from_coroutine;
```
Where a natural reading is that `value_from_resumer` is *in response to* the yielded `value_from_coroutine`. But the resumer sees it this way:
```
auto next_value_from_coroutine = co_await some_genertor(value_from_resumer);
```
Here the resumer has to prepare and inject the value before it asks the coroutine to generate its next value. This is in contradiction to the previous expectation.
I presented my intuition. It may be wrong. But the documentation does not offer any other. I believe that the value consuming interface of `async::generator` should be either removed, or justified in the docs.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.