Docs

New Features

Expression macro as caller-side argument

User-defined macros can now be used as a default argument, just like built-in macros. When user-defined macros are used as default arguments they are expanded at the call site; whereas when they are used as sub-expressions of default arguments, they are expanded at the place they are written. For example, consider the following functions using the #MyFileID macro.

Here is how the macro is expanded when it gets called from the app code.

Pack Iteration

Swift 5.9 introduced parameter value and type parameter packs, which made it possible to write generic functions that accept an arbitrary number of arguments with distinct types. The most noticeable impact was that the 10 view limit in SwiftUI is removed. With Swift 6, we can now iterate over a value pack with for-in loops. This is an advanced feature of Swift and it may significantly impact SwiftUI APIs.

Tuples Conform to Equatable, Comparable, and Hashable

Since tuples lacked the ability to conform to protocols, many developers stopped using tuples altogether in favor of structs that can conform to protocols. Tuples now conform to EquatableComparable and Hashable if their elements conform to the said protocols.

Typed throws

Swift 6 Language Mode

Sources

1 item under this folder.