Skip to content

Are value-consuming generators useful? #101

@akrzemi1

Description

@akrzemi1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions