Swiftweekly.github.io: [158] Issue #158 - April 23, 2020

Created on 9 Apr 2020  ·  25Comments  ·  Source: SwiftWeekly/swiftweekly.github.io

To contribute to this issue, simply leave a comment here. Please also review our contributing guidelines.

The current draft for this issue in _drafts/. If you want to contribute directly, feel free to open a pull request.

full issue notes

All 25 comments

Another Combine primer—this time, about materialization. 🙌🏽

https://twitter.com/jasdev/status/1248322907987685378

Introducing Resilient Decoding

The basic gist is that it allows you to mark properties in your Decodable types as @Resilient which allows them to gracefully recover from errors. You can then inspect those errors at the property or report on all errors encountered during decoding.

https://forums.swift.org/t/introducing-resilient-decoding/35212

Conform to protocols by fulfilling stricter requirements

Protocols are great to express a set of required dependencies without specifying the underlying implementation. However composition becomes difficult when some requirements are themselves expressed in term of protocols.

https://forums.swift.org/t/conform-to-protocols-by-fulfilling-stricter-requirements/35272/3

Solving the mutating slice CoW problem

Summary: https://bugs.swift.org/browse/SR-12524 describes a problem we've had since the earliest days of Swift. For years there has been talk of solving it with language features, and in fact we got one of the necessary features in coroutine accessors. I think I can now demonstrate it's the only feature we needed, and I'll propose we incorporate this capability into the standard library.

https://forums.swift.org/t/solving-the-mutating-slice-cow-problem/35297

Sketching out more efficient variadics

TLDR:

  1. Variadics and array literals both default to allocating Arrays, which usually means a heap allocation.
  2. The compiler can already stack-promote Arrays if it can prove that there are no outstanding references to the Array instance.
  3. But it's hard to do that through a non-inlinable function call.
  4. We can sidestep that problem today by using UnsafeBufferPointer.
  5. When move-only types come along, we're close to being able to make a safe BorrowedBuffer type. (Which we'll very likely want anyway, for other purposes.)
  6. If we then come up with a syntax to allow types other than Array to be used for variadic parameters, we get safe stack-allocated variadics out of it. (I don't much care what the syntax is at the moment.)

https://forums.swift.org/t/sketching-out-more-efficient-variadics/35346

SE-0282: Low-Level Atomic Operations

The review of SE-0282: Low-Level Atomic Operations begins now and runs through April 24, 2020.

https://forums.swift.org/t/se-0282-low-level-atomic-operations/35382

Include argument labels in identifiers

Ever since SE-0111, argument labels have not been part of function types. While this makes sense, it leads to a dearth of labels that can be difficult to work with.

This prompts a question: where do argument labels live? They aren’t in the type, and they obviously aren’t in the body. That leaves one place: the name.

https://forums.swift.org/t/include-argument-labels-in-identifiers/35367

[Accepted with Modifications] SE-0281: @main: Type-Based Program Entry Points

https://forums.swift.org/t/accepted-with-modifications-se-0281-main-type-based-program-entry-points/35400

Swift on Server WorkGroup April 1st, 2020 meeting notes

https://forums.swift.org/t/april-1st-2020/35408

https://developer.apple.com/documentation/xcode_release_notes/xcode_11_4_1_release_notes

Swift
Resolved Issues
Fixed a crash that could occur in Swift code that imported an Objective-C class defined with the objc_runtime_name attribute. (60888835)

Swift Packages
Resolved Issues
Fixed an issue where an error like “Swift package product A is linked as a static library by B and C. This will result in duplication of library code.” was incorrectly emitted if an app and an embedded app extension or helper tool statically linked the same package product. If you previously set the DISABLE_DIAMOND_PROBLEM_DIAGNOSTIC build setting to work around this issue, you can delete this setting now. (59310009, 61227255)

SE-0279: Multiple Trailing Closures [Amended]

The second review of SE-0279 — Multiple Trailing Closures begins now and runs through April 24, 2020.

https://forums.swift.org/t/se-0279-multiple-trailing-closures-amended/35435

Hiding / Ignoring Directories from Xcode when Opening Swift Packages

https://forums.swift.org/t/hiding-ignoring-directories-from-xcode-when-opening-swift-packages/35431

Swift on Server WorkGroup March 18th, 2020 meeting notes

https://forums.swift.org/t/march-18th-2020/35430

Renaming Trailing-closure Functions in the Standard Library

https://forums.swift.org/t/renaming-trailing-closure-functions-in-the-standard-library/35454

Pitch: Test if a type conforms to a non-existential protocol

encountered a problem when trying to optimize a generic algorithm and was a bit stuck when I had to adapt an implementation detail to whether my generic type conformed to more restrictive protocol or not. In python, a simple if isinstance(self, class) would solve the issue, but I didn't find any equivalent in swift.

The problem
Playing around with generic algorithms (in this case quickselect), I had to gather the last accessible index of a Collection. It is easy and cheap if the collection conforms to BidirectionalCollection by using

let lastIndex = index(before: endIndex)

https://forums.swift.org/t/pitch-test-if-a-type-conforms-to-a-non-existential-protocol/35479

I don't remember if this was shared before

https://gankra.github.io/blah/swift-abi/

https://twitter.com/dgregor79/status/1250608397482786816

We did, in issue 148 😄

Add modify…(…) methods to Dictionary / MutableCollection / Optional

Full proposal text | Preliminary implementation

This proposal adds the following APIs to the Swift standard library:

  • Optional:

    • modifyIfNotNil(_:)

  • Dictionary:

    • modifyValue(forKey:_:)

    • modifyValue(forKey:default:_:)

  • MutableCollection:
    *modifyElement(at:_:)

https://forums.swift.org/t/add-modify-methods-to-dictionary-mutablecollection-optional/35607

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jessesquires picture jessesquires  ·  8Comments

jessesquires picture jessesquires  ·  7Comments

jessesquires picture jessesquires  ·  9Comments

jessesquires picture jessesquires  ·  10Comments

gregheo picture gregheo  ·  3Comments