Pitch: Protocol-based Actor Isolation

The thing with CustomStringConvertible is that we pay a very high cost for the existence of this protocol. Any type is printable with a bunch of reflection, but every time we want to print a type we have to go look up whether it is CustomStringConvertible to see if there's an override. That kind of runtime lookup isn't acceptable at actor boundaries. Maybe that's not what you're suggesting?

I fully expect that we'll have some kind of UnsafeTransfer<T> wrapper struct that you can manually put a T into to turn off checking. Then your call site might be something like:

otherActor.doSomething(UnsafeTransfer(myClassInstance))

and that's fine. You can do work in the UnsafeTransfer initializer.

I accept that UnsafeTransfer can be a property wrapper so that the "unsafe" bits are hidden in the declaration of doSomething if/when parameters can have property wrappers on them, e.g.,

func doSomething(@UnsafeTransfer _: MyClass) { ... }

and the call site won't be as obvious:

otherActor.doSomething(myClassInstance)  // implicitly wrapped in UnsafeTransfer

because this keeps all of the custom work out of the actors mechanism.

Doug