Issue #101 25 Jan 2018
Written by: Bas Broek
We’re back. After a short hiatus, we are continuing Swift Weekly Brief every other week. 🎉 As Jesse mentioned, he will be taking a break from writing the newsletter. I will be taking over the curation of the newsletter for now, with the help of some awesome contributors and writers.
There is more great news: the Swift Forums are now live! They offer a more visual, searchable and navigatable way of browsing through the previous mailing lists. This will hopefully make the barrier for chiming in on everything Swift.org lower. Go have a look - and a huge congratulations to the team at Apple for realising this.
- SR-6706: Swift should complain about weak references to classes that don’t support them
Sequence.splitshould have a
- SR-6736: Enforce 16-bit limit for number of function parameters, number of tuple type element
News and community
Apple released the first Xcode 9.3 beta, which will ship with Swift 4.1.
Joe Groff’s talk at Swift Summit, Swift’s Reflective Underpinnings, has been posted and includes a transcript of the post as well.
Commits and pull requests
Pavel Yaskevich opened a pull request that could speed up the type checking of complex expressions.
Slava Pestov merged a pull request that enables API resilience in the Standard Library. He’s been working on it for two and a half years (!). It was one of the three main goals to achieve ABI stability.
The review of “SE 0192 - Non-Exhaustive Enums” had extensive discussion and has been returned for revision.
The proposal author, Jordan Rose, is working on a revised proposal that includes:
- Alterations to the naming of the attributes.
- New affordances for how
switchstatements work with non-exhaustive enums.
There will be a second round of review, but there is active discussion considering the latter point right now on swift-evolution on the thread “Handling unknown cases in enums”.
Proposals in review
We propose the introduction of a protocol,
ValueEnumerable, to indicate that a type has a finite, enumerable set of values. Moreover, we propose an opt-in derived implementation of
ValueEnumerablefor the common case of a simple enum. The compiler will derive an implementation automatically for simple enums when the conformance is specified.
This proposal introduces a new
DynamicMemberLookupProtocoltype to the standard library. Types that conform to it provide “dot” syntax for arbitrary names which are resolved at runtime - in a completely type safe way. It is simple syntactic sugar which has a non-invasive implementation in the compiler.
This proposal introduces
#errordirectives that will cause the Swift compiler to emit a custom warning or an error during compilation.
Michael Ilseman gave an update on the State of String in regard to the ABI, performance, ergonomics and more.
I’ve been working on implementing, optimizing, and improving String in preparation for ABI stability, and I thought I’d share the current status of String in Swift 5 and some potential directions to go. This is the product of conversations with open source contributors and my colleagues on the Swift standard library team at Apple.
Chris Eidhof pitched adding a function to toggle a Bool:
Boolvariables, it is common to want to toggle the state of the variable. In larger (nested) structs, the duplication involved can become especially annoying:
It’s also easy to make a mistake in the code above if there are multiple
Boolvars. [The proposed solution is to] add a method toggle on
This allows us to write the example above without duplication:
And finally… the Access Control debate continues.