+
Skip to content

Conversation

lionel-
Copy link
Member

@lionel- lionel- commented Oct 31, 2024

We now return exhausted() instead of last_value() in generators. Fixes #51.

This is different from the JS behaviour where an iterator is allowed to return a value with the exhaustion sentinel, e.g. {value: "something", done: true}. In contrast we discard the return value entirely. This is consistent with our sentinel model and simpler. I may be missing a use case for returning the value as in JS but I don't think we're missing out much?

The generator state machines still keep track of last values because this is used in async functions where we do want to return that value.

@lionel- lionel- requested a review from jcheng5 October 31, 2024 11:19
@jcheng5
Copy link
Member

jcheng5 commented Nov 4, 2024

Definitely the right change. Are you worried about this breaking existing code out there?

@lionel-
Copy link
Member Author

lionel- commented Nov 5, 2024

Are you worried about this breaking existing code out there?

A bit worried, but I'm more worried about getting the API right for future users, especially if coro usage increases with new Shiny / elmer use cases.

@lionel- lionel- force-pushed the feature/ignore-return branch from c4a50e7 to 3d136aa Compare November 5, 2024 07:53
@lionel- lionel- merged commit 9dc9bc8 into main Nov 5, 2024
10 checks passed
@lionel- lionel- deleted the feature/ignore-return branch November 5, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignore return values of generators?

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载