[Revision/Pitch] `Iterable` (formerly `BorrowingSequence`)

I am still very much in favor of this overall, but I have a few questions after having played with this new iteration type from swift-collections extensively in the past weeks and re-reading the updated proposal.

Now that we renamed BorrowingSequence to Iterable, have you thought about how the other types of iteration alluded to in the future directions section would be named?

Can we clarify the termination semantics and expectations of IterableIteratorProtocol in the type's docs to reflect what the proposal specifies? In particular, can we expand the proposal and docs to also clarify the semantics of what happens if the iterator throws? I expect that after an iterator throws, it must return empty spans. Similarly, once an iterator returned an empty span, it must continue returning empty spans.

The default skip implementation is missing a typed throws annotation in the proposal. Is this intentional or just an oversight?

Should OutputSpan and OutputRawSpan also adopt Iterable similar to the other adoption of the other span types?

I like the introduction of the Failure generic parameter. I have been prototyping new asynchronous streaming APIs that we are using in the new HTTP client and server proposals. Those types, similar to AsyncSequence, also have the concept of a Failure. In addition to a Failure, I am currently working on the notion of a final element. My initial thinking was that final elements could be HTTP-specific; however, it turns out many network and file protocols have the notion of a final element, such as HTTP, Quic, gRPC, TLS, gzip, and more. I don't want to derail this proposal too much, and I understand synchronous iteration is something different than asynchronous streaming. I was mostly curious if you have thought about this. A hypothetical desugared syntax could look like this:

let finalElement = for element in myIterable {
  print(element)
}
1 Like