It’s November! The days get shorter, and the end of year is creeping up. Swift 5 is drawing nearer. This issue is also guaranteed not to be spooky.

Interested in sponsoring Swift Weekly Brief? Learn more here.

Starter tasks

  • SR-8937 [Compiler] Switch over T? fixit does not use syntactic sugar
  • SR-8960 [Compiler] Emit a symbol reference to ensure swiftrt.o is linked on Linux/Windows

News and community

Apple released Xcode 10.1, along with Swift 4.2.1. It includes an overview of what’s new in this Swift version.

Ankit Aggarwal shared that SwiftPM can now generate code coverage data!

Doug Gregor and Ben Cohen’s talk on generics at WWDC has been expanded to include an all-new section on recursive constraints, associated type and protocol where clauses, and divide-and-conquer algorithms. It starts at around 33 minutes. Highly recommended; very insightful!

Commits and pull requests

Pavel Yaskevich merged a pull request that replaces one of the last remaining places where curry levels were still used by diagnostics.

Rintaro Ishizaki merged a pull request that improves completion for the index part of a subscript expression, allowing the compiler to help you use more complex subscripts.

Accepted proposals

SE-0230: Flatten nested optionals resulting from try? was accepted.

The Core Team does not want to make source-incompatible changes lightly, but we also want to leave room to improve the language for future users of Swift. We don’t have a bright-line rule for when a change crosses the line to become unacceptable, but the key consideration in our analysis is the change’s apparent impact in practice on existing code more than its hypothetical risks. In this case, we are convinced that the change leads to fairly inarguably better results.

SE-0232: Remove Some Customization Points from the Standard Library’s Collection Hierarchy was under review.

This proposal removes four customization points from protocols in the standard library:

  • map, filter, and forEach from Sequence
  • first, prefix(upTo:), prefix(through:), and suffix(from:) from Collection
  • last on BidirectionalCollection

The default implementations of these symbols will remain, so sequences and collections will continue to have the same operations available that they do today.

… and has been accepted.

The Core Team has decided to accept the proposal as written (with the refinements incorporated during the review).

Swift Forums

Jon Shier wrote a second pitch to add a Result type to the standard library.

Result is considered generally useful enough to be included in the standard library. However, in the past, strenuous disagreement between the typed and untyped-throws camps has prevented consensus on the exact form it should take.

To kick off another round of discussion, and before I update my proposal officially, I’d like to discuss the form that was brought up late in the last discussion:

enum Result<Value, Error> {
    case success(Value), failure(Error)
}

The proposal can be found here.

Finally

How to learn all about generics with this one easy trick!