SE-0302 (second review): Sendable and sendable closures

I agree that @concurrent is stronger, and I also think it is generally more understandable and meaningful: a @concurrent function can be executed concurrently, whether with itself or with respect to the place it was formed. That implies that it conforms to Sendable.

As much as I would want the Sendable/@sendablenaming to line up, I think@concurrent` remains the better name for the attribute.

I agree that this makes a lot of sense, and am happy to ban such extensions.

I agree that the latter is the clearest option, and the only one we should support.

I tend to agree with you. As I've noted before and has been mentioned here, I am not at all concerned about types that start out being Sendable and then add some reference-type-ish field that makes them not Sendable. We have tools that catch it, and one has almost surely also broken value semantics with such a change, which will be the bigger surprise.

This is a good point. The implicit Sendable makes it much more likely that we'll end up with a surprise with unsafe pointers.

It's an important optimization, because the vast majority of types will conform to Sendable one way or another. It also makes it possible to introduce Sendable conformances in a manner that can be backward-deployed.

I think this is a good feature to make public at some point in the future, because there are undoubtedly other semantic tags we might want later (e.g., the ValueSemantics protocol idea that came up in earlier pitches).

The language does not have per-conformance annotations yet, although the idea has come up for a couple of other reasons:

  • @available on conformances is a recent addition (Swift 5.4), and is currently inferred from the availability of the extension. We could narrow this to an annotation on the specific conformance that has availability.
  • @retroactive on a conformance could acknowledge that a conformance is in neither the original type's module nor the protocol's module. Retroactive conformances can cause of some confusion, so there's a possible future where folks want to know about them and mark them as such explicitly.
  • Actors pitch #4 has a "future direction" for isolated conformances.
  • Scoped conformances could put access control on the specific conformance.

The compiler can generate Fix-Its to help migrate code, and IDEs or other tools can help you apply those Fix-Its.

Doug

2 Likes