Swift 5.2 takes flight

Swift 5.2

After a good half year of work, Swift is now available in version 5.2, bringing key path expressions as functions and callable values of user-defined nominal types to Apple’s general-purpose language.

The two features mentioned are a result of the Swift Evolution process and show ways to realise more functional programming concepts. Callable values for example define function-like behaviour and can be called using function call syntax, something that wasn’t an option before.

The feature “supports statically declared arities, argument labels, and parameter types, and is not constrained to primary type declarations” and can be useful for things like lightweight API design or domain-specific languages. “Key Path Expressions as Functions” meanwhile can, among other things, make code more compact in cases where the aim is to extract pieces of data from a property.

Given searching for errors is always a pain, devs will be pleased to hear that the Swift team has improved error messages in the Swift compiler. While the messages in earlier versions tended to not be very precise for certain kinds of errors, version 5.2 should be more helpful thanks to some alterations in the type checker, giving it ways other than guessing to locate bugs.

Advertisement

The type checker is also said to use “a new centralized logic for caching, lazy evaluation, and dependency tracking between requests, where a request is a self-contained unit of computation”. This is meant to make incremental builds more efficient, since the new logic supersedes a previously used validation step which could become quite wasteful due to the amount of pre-computations it ran.

Those relying on code completion to keep the number of mistakes made during coding to a minimum should experience a speed-up with the new release. Code completion now also promises more legible type displays and to “supply names of implicit members for incomplete dictionary literals and incomplete ternary expressions”.

Swift Package Manager also received some improvements, so that it now uses a better quality strategy to resolve package dependencies.

Swift 5.2 binaries for Ubuntu are available via the language’s website, while developers for the Apple platform will find it embedded into the Xcode 11.4 release. The source code can be found on GitHub.

- Advertisement -