You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Region-based isolation works without any code changes. But a function’s parameters and return values can also explicitly state that they support crossing domains using this mechanism.
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. Without sending, this function would only be possible to implement by requiring that Chicken first conform to Sendable.
Based on this, I don't feel like I understand how to reason about using sending. Is the compiler still going to guarantee safety, or is this a foot gun? If it still guarantees safety, how is it any different than omitting sending? Another sentence or two, or a reference to a more detailed explanation, would be helpful.
The text was updated successfully, but these errors were encountered:
Yes, I agree. There is no unsafety here. But, this example in isolation doesn't make it clear enough that withoutsending, this code will not compile because the compiler cannot guarantee that chicken can be transferred across domains.
https://www.swift.org/migration/documentation/swift-6-concurrency-migration-guide/dataracesafety#Flow-Sensitive-Isolation-Analysis
The text on it is as follows:
Based on this, I don't feel like I understand how to reason about using
sending
. Is the compiler still going to guarantee safety, or is this a foot gun? If it still guarantees safety, how is it any different than omittingsending
? Another sentence or two, or a reference to a more detailed explanation, would be helpful.The text was updated successfully, but these errors were encountered: