[Pitch] Global actors

Yes, one can use __attribute__((swift_attr("@MainActor"))) to state that an Objective-C declaration will always be called on the main actor. Of course, we can't verify that from the Objective-C side, but it makes annotation possible. This is documented in SE-0297, albeit somewhat indirectly because we hadn't written up the global-actors pitch fully at that time.

Ignoring the private, the declaration in Objective-C could use the attribute I mentioned above. And yes, it's completely unsafe from the Objective-C side--we've had to live with that in Swift since day 1, where (Objective-)C code can freely violate the safety guarantees otherwise provided by Swift, and I think it's okay to do the same thing here.

I'll bring some discussion of this into the proposal, thank you!

Doug

3 Likes