Swift 5.10 Released
Swift was designed to be safe by default, preventing entire categories of programming mistakes at compile time. Sources of undefined behavior in C-based languages, such as using variables before they’re initialized or a use-after-free, are defined away in Swift.
An increasingly important source of undefined behavior is concurrent code that inadvertently accesses memory from one thread at the same time that another thread is writing to the same memory. This kind of unsafety is called a data race, and data races make concurrent programs exceptionally difficult to write correctly. Swift solves this problem through data isolation provided by actors and tasks, which guarantees mutually exclusive access to shared mutable state. Data isolation enforcement has been under active development since 2020 when the Swift concurrency roadmap was posted.
→ swift.org/blog/swift-5.10-released/
Swift 5.10 achieves full data isolation in its concurrency model, enforcing compile-time checks to prevent data races when using the -strict-concurrency=complete
flag, building on features like async/await and actors from Swift 5.5 and Sendable
from Swift 5.7.
It introduces the nonisolated(unsafe)
keyword to opt out of actor isolation for specific properties or variables, reducing reliance on @unchecked Sendable
for cases with external synchronisation, such as OS primitives.
The release fixes bugs in Sendable and actor isolation checking, ensuring robust data-race safety, though some false positives remain, targeted for improvement in Swift 6’s new language mode. Developers can test complete concurrency checking, report bugs, and provide feedback on Swift forums to shape the Swift 6 transition, with ongoing proposals to enhance usability and reduce unnecessary warnings.
Category:
Tag:
Year: