The latest version of Swift introduces support for phased adoption of upcoming features, allowing developers to start using new features that will become stable in Swift 6, infoq reports. The new release also offers retroactive delivery of new features in earlier operating systems.
The main reason Swift 5.8 supports upcoming language features is to allow developers to start preparing for the migration of their programs. Additionally, the new feature may help Apple gather feedback from early users.
Upcoming feature support is controlled by a new compiler flag, -enable-upcoming-feature X, where X is the feature to enable. At the moment, there are four upcoming features that can be selectively enabled in Swift 5.8: concise magic file names, [forward-scan matching for trailing closures](Forward-scan matching for trailing closures), existential any, and regex literals.
To make sure an upcoming feature is actually available before using it, a new #if check is available, #if hasFeature(ImplicitOpenExistentials), which can be used along with a compiler(>=x.y) check, in case it is needed.
Another area where Swift 5.8 brings significant change is result builder implementation, which improves compile-time performance, code completion results, and diagnostics. The new implementation leverages Swift 5.7 extended multi-statement closure inference, which enables the compiler to optimize type inference and error messages. Developers will welcome the removal of several limitations on local variable declarations in result builders, such as the requirement to have an initializer, and lack of support for computed variables, observers, and property wrappers.These are just some of the additional changes Swift 5.8 offers.