in SE-0414 there are some examples of isolation regions changing through a program
- In these examples of isolation regions, we quote the rules in 3 as written, but in the rule
yis the returned value, while in the examples,xis the assigned (returned) value.
assigning a
varbinding.y = x. Assigning a var bindingywithxresults inybeing in the same region asx. Ifyis not captured by reference in a closure, theny's previous assigned region is forgotten due to(3)(b):func mutableBindingAssignmentSimple() { var x = NonSendable() // Regions: [(x)] let y = NonSendable() // Regions: [(x), (y)] x = y // Regions: [(x, y)] let z = NonSendable() // Regions: [(x, y), (z)] x = z // Regions: [(y), (x, z)] }In contrast if
ywas captured in a closure by reference, theny's former region is merged with the region ofxdue to(3)(a).// Since we pass x as inout in the closure, the closure has to capture x by // reference. func mutableBindingAssignmentClosure() { var x = NonSendable() // Regions: [(x)] let closure = { useInOut(&x) } // Regions: [(x, closure)] let y = NonSendable() // Regions: [(x, closure), (y)] x = y // Regions: [(x, closure, y)] }
the isolation regions change from (x,y),(z), to (y),(x,z) in combination with the literal rule quote could confuse the readers to think the old isolation group of y was forgotten to achieve this. can we edit this examples? either:
- changing all the examples to other names like
a,b,c - swaping
xandy - clarifying while quoting rule 3 to which variables in the example it applies
can help understanding the examples
- rule 3.b itself may be further clarified, maybe with a more complicated example.
If
ywas not captured by reference, theny's old region is forgotten.
the example changing from (x,y),(z), to (y),(x,z) , doesn't fully explain the meaning of "y's old regoin is forgotten". is the whole region erased (i think not)? or just y taken out of it? (x,y,a),(z) goes to (y),(a),(x,z)or to (y,a),(x,z)? i'm pretty sure the second option is correct, but neighter the rule wording, nor the examples, make me know. Can we change the rule/examples to make it a bit more clear?