TIL `sending` keyword in Swift
Read Migrating to Swift 6.
TIL sending
keyword in Swift:
func populate(island: Island, with chicken: sending Chicken) async {
await island.adopt(chicken)
}
The compiler can now provide the guarantee that at all call sites, the
chicken
parameter will never be subject to unsafe access. This is a relaxing of an otherwise significant constraint. Withoutsending
, this function would only be possible to implement by requiring thatChicken
first conform toSendable
.
Hm. actors could be passed between isolation domains. Here’s quote from Migrating to Swift 6:
Actors are not value types, but because they protect all of their state in their own isolation domain, they are inherently safe to pass across boundaries. This makes all actor types implicitly
Sendable
, even if their properties are notSendable
themselves.
Watched PointFree episode Cross-Platform Swift: View Paradigms.