-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a proposal to generalize AsyncSequence and AsyncIteratorProtocol.
#2264
Conversation
5c35e81
to
d4bfe25
Compare
| ## Introduction | ||
|
|
||
| This proposal generalizes `AsyncSequence` in two ways: | ||
| 1. The bespoke `@rethrows` attribute is replaced with proper `throws` polymorphism via adoption of typed throws. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do wonder how much discussion of @rethrows is appropriate given that it's never been an official feature. Perhaps makes sense to mention as an aside below but I don't know if it warrants callout up-front?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this to just say proper throws polymorphism is accomplished with typed throws adoption.
|
|
||
| #### Error type inference from `for try await` loops | ||
|
|
||
| The `Failure` associated type is only accessible at runtime in the Swift 5.11 standard library; code running against older standard library versions does not include the `Failure` requirement in the witness tables for `AsyncSequence` and `AsyncIteratorProtocol` conformances. This impacts error type inference from `for try await` loops. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would potentially make more sense to move this below a couple paragraphs, once we've introduced what the inference behavior actually is (i.e., as a caveat to the MyAsyncIterator example, and just before "When the throw error type of an AsyncIteratorProtocol..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh hmm, I meant this as a general statement that doesn't just apply to error type inference in for try await loops. Maybe I should move this up into the previous section to describe why the Failure associated type has Swift 5.11 availability. Then this section can say that because Failure is only available in Swift 5.11, thrown error type inference depends on availability context. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that reorganization makes sense to me!
Co-authored-by: Laszlo Teveli <tevelee@users.noreply.github.com>
Co-authored-by: Luca Bernardi <luka.bernardi@gmail.com>
separate proposal.
* Move discussion of the experimental `@rethrows` out to "Source Compatibility" * Rename `nextElement(_:)` to `next(isolation:)`
No description provided.