[Pitch] Distributed Actors

This is super exciting! I’ve only given it a quick read, but one thing stands out already:

It feels like distributed actors are begging for typed throws. If Swift supported typed throws, in addition to the other restrictions on distributed methods, you could also have the restriction that any errors thrown must conform to Codable.

That would avoid the weird situation where a thrown error can’t be sent over the wire, or is unsafe to send over the wire. Assumptions around which errors are safe to send would then be clearly documented in the method’s signature: if it’s an error thrown from a distributed method, it’s going to be sent, and so it must be safe to send, just like arguments to distributed methods and return values from distributed methods must be safe to send.

(Personally, I’ve been skeptical of typed throws before, but this feels like an extremely compelling case for them.)

9 Likes