How to Implement Scope Functions Compatible with Concurrency?

Yes, the sending requirement propagates to callees because you have to prove to the compiler that the non-Sendable value you want to return is safe to send to another isolation domain. This is described in SE-0430: sending parameter and result values.

In your new example, you'd have to make the return type of the createNS function sending too. I don't know of a way to avoid this. Perhaps the upcoming(?) pitch Closure isolation control would help with this?

1 Like