boostorg / boostorg/cobalt

Are value-consuming generators useful?

Offen
#101 7 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
347
Forks
47
Ø Merge
3 T. 8 Std.
Gemergte PRs (30 T.)
1

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.