Pitch #3: ConcurrentValue and @concurrent closures

Can you clarify what you mean here?

This proposal chooses to limit this [implicit ConcurrentValue conformance synthesis] to non-public types because Swift generally wants extra attention paid to the public APIs of types, but we could make autosynthesis happen independent of access control, or we could make it only happen when explicitly opt’d into.

The way I read it, it seems you mean the following struct would require an explicit conformance to ConcurrentValue, because it is public:

public struct Point {
  let x, y: Int
}

One danger I see with this approach is that we don't distinguish between the "this is a public type that can be used concurrently because all of its members are ConcurrentValue" and "this is a public type, who's members are not all ConcurrentValue, but the synchronization of those members is handled by the implementation".

I think we should just extend auto-synthesis of ConcurrentValue to public types, since I haven't yet figured out a way to misuse such a value. Failing this, I think we at least need to capture the intent of "I just want the implicit synthesis for this public type" (which would emit errors for non-ConcurrentValue members) versus "The implementation of this type makes it safe to use concurrently" (which would happily allow non-ConcurrentValue members). I have no opinions about how these two cases should be spelt.

2 Likes