I like the isolatedTo label. I agree that it's worth having some API design guidance around adopting isolated parameters, especially because I anticipate there will be other functions that will accept a parameter and do nothing with it other than isolated the function to it.
It's worth noting that freeing up actors was not the only motivation for SE-0338. The other major motivation for SE-0338 was Sendable checking, because without SE-0338, non-Sendable state could end up being inadvertently shared because a non-Sendable parameter to a nonisolated function could cross an isolation boundary over a suspension point within that function because it resumes on some other executor.
I agree that it's worth elaborating on the possible performance changes in the proposal. In some cases, eliminating unnecessary hops to the generic executor could end up improving performance despite having fewer suspension points when iterating over an AsyncSequence on the MainActor.
Also, somebody does notice a performance problem in their AsyncSequence iteration, and they can force the source sequence to be in a disconnected region, they can explicitly call nextElement() and pass in nil so that nextElement() runs on the generic executor. I think that's an important aspect of this proposal, and the reason I chose to use an explicit isolated parameter instead of something like isolated(caller) from the actor inheritance proposal.
I think so, because any Actor is a class-constrained existential, and embedded Swift code that uses actors has to be in the allocating subset anyway.
I can't immediately think of any problems that wouldn't already exist if we adopted typed throws in the AsyncSequence algorithms as part of this proposal. We need to consider the impact on overload resolution in contexts where both the old and new overload are available. The overloads will also need to be tied to the availability of the Failure associated type regardless of whether they're added now or later.
We discussed this in the Language Steering Group meeting. The witness checker already diagnoses using default implementations that are unavailable or obsoleted, so the fact that deprecation isn't considered is just a compiler bug. I also learned that you can tie availability to language mode, so I think we want the default implementation of nextElement() to be unconditionally deprecated, and obsoleted in Swift 6.
There was originally a question in one of the isolation region discussions about whether that proposal would just allow the non-Sendable iterator to be passed across isolation boundaries for the next() call, but that only works if the iterator is in a disconnected region. That generally will not be true for non-Sendable async sequences unless they're created and used entirely locally, which is not how most code that uses AsyncSequence in an actor-isolated context works.
I do think that the future directions of region isolation may be useful for AsyncSequence and other concurrency APIs independent of this proposal. For example, today it's possible to use CheckedContinuation, AsyncStream.Continuation, etc to smuggle non-Sendable values across isolation boundaries using yield. We could require yield to accept a Sendable parameter, but that'd be extremely prohibitive. Instead, yield should probably accept a transferring parameter, which can be satisfied either by a Sendable value or a non-Sendable value in a disconnected region. If we do that, it may be possible to mark the result type of nextElement() as transferring / "returns isolated", which would make it valid to iterate over an AsyncSequence of non-Sendable values in an actor isolated context while passing nil to nextElement() because you explicitly want it to run on the generic executor.
But even if we could make all the concurrency warnings go away with just region isolation, that wouldn't solve the issue of excessive hops to the generic executor. For example, in cases where the computation for the next element is isolated to some other actor, next() would hop to the generic executor only to turn around and immediately hop to some other executor. I think isolating next() to the calling actor is the right default, while still providing tools for either isolating the element-producing closure, or explicitly isolating nextElement with the isolated argument.
None of us are happy with the back deployment restrictions in the proposal, but we have not come up with a solution that's actually feasible. Even if we did come up with a way to let you use primary associated types, they would have to be limited in what you can do with them. For example, you would not be able to dynamic cast to type any AsyncSequence<T, Never>.