Tuesday, February 22, 2022 [Tweets] [Favorites]

Swift 5.6 Features in Xcode 13.3 Beta 3

Apple:

Swift now allows existential types written with the any keyword. An existential type is a type that can hold a value of any type conforming to a specific protocol. The any keyword creates a syntactic distinction between existential types and protocol conformance constraints. The any keyword is an important syntactic indicator that you’re using an existential type, because there are fundamental limitations on the capabilities of these types, such as the inability to conform to protocols. [SE-0335]

[…]

Swift now provides an incremental migration path for data race safety. APIs can adopt concurrency without breaking clients that haven’t adopted concurrency. An existing declaration can introduce concurrency-related annotations (such as making its closure parameters @Sendable) and use the @preconcurrency attribute to maintain its behavior for clients who haven’t adopted concurrency[…] [SE-0337]

[…]

The standard library now provides the withUnsafeTemporaryAllocation(of:capacity:_:) and withUnsafeTemporaryAllocation(byteCount:alignment:_:) functions. You can use these functions to cheaply allocate raw storage for a brief duration. The system allocates storage on the stack if possible. [SE-0322]

Previously:

Update (2022-03-07): Paul Hudson:

Swift 5.6 introduces another barrage of new features to the language, while refining others as we get closer to Swift 6. In this article I want to introduce you to the major changes, providing some hands-on examples along the way so you can see for yourself what’s changing.

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment