Issue #193 09 Sep 2021
Written by: Kristaps Grinbergs
California streaming. We all know what that means: a big day is coming next week - Apple has announced an event on September 14! They hid an easter egg inside the event invitation - a hidden AR experience, and it looks pretty cool. This also allowed fans across the globe to speculate about what upcoming products Apple is going to announce. It was suggested that the rose gold color of the skies inside the portal gives us the first glance of the new iPhone’s colors. Well, we’ll find out in less than a week.
The last two weeks have been full of activities in the Swift community. Many proposals are being generated in Swift evolution; some have been accepted or returned, and some are still in review. These proposals help to facilitate Swift remaining a modern language, so let’s keep them rolling!
I want to thank everyone in the Swift community involved in this project. If you want to support our newsletter financially, please reach out as we have a few sponsorship slots available.
Interested in sponsoring Swift Weekly Brief? Learn more here.
News and community
Commits and pull requests
The feedback from the review was positive, and members of the community suggested several improvements that the author and core team felt would be good to adopt:
- Adding conformance for
CodingKeyRepresentablewhich will allow the natural use of
CodingKeyRepresentableis used as a generic constraint.
- Make the initializer of the
CodingKeyRepresentableprotocol be generic.
- Provide default implementations for the conformance for
- Make the initializers of the internal
Proposals in review
The second review is focused on the proposed improvements made by the community during the first review, and addressed by swift-evolution#1435.
This proposal introduces new Standard Library functions for manipulating temporary buffers that are preferentially allocated on the stack instead of the heap.
Swift-evolution thread: [Pitch] Temporary uninitialized buffers
There are many cases when jurisdiction of error handling is unclear. Developers may question whether to handle or propogate errors.
Choosing to throw errors provides the benefit that callers can flexibly handle problems.
Choosing to not throw errors provides the benefit of simplifying syntax to users (no
I’m getting ready to release version 0.2.0 of WebURL. It’s going to be an exciting and important release, including a
WebURLSystemExtrasmodule for integration with
swift-systempackage, and aligning the project with the very latest revision of the URL Standard.
Destructuring assignment is a language feature that allows you to extract multiple parts of a value and assign them to multiple variables within a single assignment statement.
Austin started a conversation about netlink socket support in SwiftNIO.
With the recent introduction of Swift concurrency, and most notably actors to the language, Swift gained powerful and foundational building blocks for expressing thread-safe concurrent programs. This proposal aims to extend Swift’s actors with the ability to work equally well for distributed systems thanks to the introduction of distributed actors and location transparency associated with them.
This release matches upstream Swift 5.4, and allows you to compile Swift apps (as long as they don’t use code specific to other platforms) to WebAssembly, and even run them in the browser.
As Swift libraries and packages are more widely distributed, module names sometimes end up clashing. As there’s no module namespace yet in Swift, libraries are often forced to be renamed or pinned to an older non-conflicting version in such case. This makes use cases such as the following challenging:
Adding a new dependency or upgrading as it can introduce a collision: A new (or upgraded) module can have the same name as another module already in the dependency graph. Module name Logging is a common example.
Upgrading to a newer version of a package from an older version pinned by an upstream library: Consider a scenario where MyApp depends on module Lib, and Lib depends on module Logging. MyApp also depends on Logging. If Lib is pinned to Logging 1.0.0, MyApp is stuck with the same version 1.0.0.
Swift on the Server Workgroup, on September 3rd, 2021, announced a special update.
Swift is a language that allows us to write expressive API interfaces. With features like constrained Generics, method overloading, trailing closures, and default arguments, you can reduce code duplication while still achieving quite flexible APIs. This proposal aims to increment this part of the language with
@expanded, a new attribute for function parameters.
This thread is the love child of two previous contentious threads [Pitch] Introducing the “Unwrap or Die” operator to the standard library 2 and more recently Moving toward deprecating force unwrap from Swift?. The latter thread did not reach a conclusion other than being locked and this thread picks up on the former thread proposing instead an “Unwrap or Throw” operator might be a better solution to the problem of forced unwraps in Swift which bugs me and I’m sure it bugs our users when their apps crash out.
In short, I’d like to propose a
!!operator, a cross between a forced unwrap and nil coalescing that throws if an optional is nil..