[Pitch #2] Global actors

I didn't pay much attention to the first pitch so sorry if I'm repeating questions.

As Zhu_Shengqi points out, it feels a bit weird that we mark @globalActor a type that is not an actor, and the global actor is something that type returns.

The alternatives proposed talks about singleton. I'm fine with not adding that to the language and just using @globalActor, but why not attaching that attribute to the actor itself and just require it to return a shared instance itself?

To eliminate these data races, we can require that every global or static variable do one of the following:

is not clear to me if that's just a suggestion (as in, the proposal allows us to do this in the future and is very nice) or is the proposal adding these new rules to Swift?

Using global actors on a type
It is common for entire types (and even class hierarchies)

When seeing this in UIViewController I'm starting to see the appeal for Revisiting “nonisolated let” with more implementation, usage, and teaching experience ...

A minot nitpick on the text: In Using global actors on functions and data the code example is a UIViewController but the text mentions AppKit. Nothing to do with the topic at hand but may confuse some people.

Overall I'm very excited for this part of the actor system. It will make working with UI frameworks much safer and nicer! <3

1 Like