Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What’s new in Swift 5.0

What’s new in Swift 5.0

Alex Nadein

Alexander Saenko

February 23, 2019
Tweet

More Decks by Alexander Saenko

Other Decks in Programming

Transcript

  1. ABI stability ABI is an interface between two binary program

    modules. The ABI usually covers the following things: • CPU instructions (registers, stack organization, memory access type) • sizes, layouts and alignments of data types • calling convention (how to call functions, pass arguments, return values) • system calls to the OS
  2. ABI stability ability of language means it can be packaged

    and linked directly into the operating system No need to package the Swift dylib into apps. Lighter apps and other benefits.
  3. ABI stability Swift ABI & API stability Better version compatibility

    Easier project migrations to newer Swift versions ( And even backward compatibility! )
  4. ABI stability Swift ABI stability eate closed source 3rd-party libraries

    written in Swift and distribute them as pre-compiled No need to share your source files & Speed up project build times.
  5. @dynamicCallable logical extension of @dynamicMemberLookup It allows the instance of

    RandomNumberGenerator to be called like a function. Alternate method withKeywordArguments for calling the type with parameter labels.
  6. @dynamicCallable • You can apply it to structs, enums, classes,

    and protocols. • If you implement withKeywordArguments: and don’t implement withArguments:, your type can still be called without parameter labels – you’ll just get empty strings for the keys. • If your implementations of withKeywordArguments: or withArguments: are marked as throwing, calling the type will also be throwing. • You can’t add @dynamicCallable to an extension, only the primary definition of a type. • You can still add other methods and properties to your type, and use them as normal.
  7. @unknown This attribute will warn you when enum will be

    changed and your switch block is no longer exhaustive
  8. try? Result type is String?? In Swift 4.2 and earlier

    optional optionals was the thing. Using try? on throwing method with optional return type end up with a nested optional.
  9. try? Result type is String? In Swift 5.0 and later

    try? won’t wrap values in an optional if they are already optional.