Swift Async Algorithms: Design Guidelines

Thank you so much to everyone that contributed their thoughts to this thread. It’s been a really useful exercise. It’s certainly opened my eyes to some things that I hadn’t considered before, and I’m grateful for that.

Gathering the feedback from the comments above, there appears to be a broad consensus, with one notable exception:

  • 2.2.4: If an asynchronous sequence is Sendable, it MUST be safe for its iterators to co-exist across Tasks. This is because it is possible for more than one Task to iterate a Sendable asynchronous sequence at the same time.

The community felt that this rule was at odds with the existing aims of consistency with synchronous Sequence types, for which no specific multi-pass behaviour is defined. Specifically, the documentation for Sequence states: “ [the Sequence] protocol makes no requirement on conforming types regarding whether they will be destructively consumed by iteration.” Therefore, this guideline has been removed in its entirety.

Thanks again, all, for your valuable input.

2 Likes