Skip to content

Allow return of effects using yield-effects rule? #81

Open
@blordpluto

Description

@blordpluto

Sometimes it's necessary and idiomatic to directly return the result of an effect. Using the yield-effects linter rule in this case motivates the usage of return yield effect() syntax which feels odd.

For generators in general, both yield and return expressions result in values being returned. Both are legit outputs. Sandwiching the extra yield inside there doesn't actually appear to be necessary. There's no reason to pause the generator before ending it. You can just end it. So return yield "works", but it seems strange for a linter to insist on. 🤔

This maybe doesn't come up for people because most generators probably primarily deal with yields. Note that return yield could have specialized uses in non-saga generators: https://stackoverflow.com/a/42309429

If I'm wrong about this I would be grateful for any clarification.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions