Swift.org blog: Swift 5 Exclusivity Enforcement

There is a new blog post titled Swift 5 Exclusivity Enforcement, authored by @Andrew_Trick, that is now available to read. It discusses how the policies for memory exclusivity have further matured in Swift 5.

If you have any questions about the material of that blog post, please feel free to post them here!

25 Likes

Am I correct that, at least where structs are concerned, a closure capture list will also avoid the overlapping access? Where the blog post says:

let incrementBy = count
modifyTwice(&count) { $0 += incrementBy }

It should be equivalent to write:

modifyTwice(&count) { [count] in $0 += count }

Right?

6 Likes

Right, the capture list causes a copy from an instantaneous access to happen at the point of closure formation, which would be before the formal inout access to count begins.

6 Likes