Swiftweekly.github.io: [151] Issue #151 - January 16, 2020

Created on 19 Dec 2019  ·  47Comments  ·  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

Most helpful comment

All 47 comments

Pitch: Modify Accessors

For more information on the performance implications of this change and why it's an important feature to add, you might also find this talk from last year's Functional Swift Conference useful.

Proposal
We propose the introduction of a new keyword, modify, for implementing mutable computed properties and subscripts, alongside the current get and set.

https://forums.swift.org/t/pitch-modify-accessors/31872

That pitch was referenced in issue 150 already 😊

Azure Functions Swift support

I've been working on adding Swift Support to Azure Functions. The framework supports the most popular triggers and bindings like Http, Queue, Table, Blob & Service Bus. More bindings/triggers support will be added soon! Swift Azure Functions are deployable to been tested on Azure.

https://github.com/SalehAlbuga/azure-functions-swift

https://forums.swift.org/t/azure-functions-swift-support/31939

[Accepted] SE-0273: Package Manager Conditional Target Dependencies

e review of SE-0273: Package Manager Conditional Target Dependencies ran from December 13th to December 20th, 2019. Feedback was positive, and the proposal is accepted. Thanks to everyone who participated!

https://forums.swift.org/t/accepted-se-0273-package-manager-conditional-target-dependencies/31932

[Accepted with Modifications] SE-0272: Package Manager Binary Dependencies

The second review for SE-0272: Package Manager Binary Dependencies ran from December 13th through December 20th, 2019. You can find the review thread here.

Feedback was sparse, but we had generally positive feedback during the first round of review. Therefore the proposal has been accepted with modifications, local binary targets will not be able to reference zipped artifacts.

https://forums.swift.org/t/accepted-with-modifications-se-0272-package-manager-binary-dependencies/31926

Open API Tools & Swift - Personal Experience

This post is meant to illustrate the current state of tooling for Server Side Swift projects written from the perspective of someone who is still very new to Swift, and is probably making some assumptions that may prove to be incorrect

Project: https://github.com/spprichard/Swifternetes

https://forums.swift.org/t/open-api-tools-swift-personal-experience/31962

We’ll see if we include this.

Passing Custom Getter And Setter To Property Wrapper Initializer

A lot of use cases for property wrappers (like SwiftUI's @Binding or a simple @Lazy) rely on custom accessor closures of the form () -> WrappedValue and (WrappedValue) -> Void for the getter and the setter respectively. To that end, I'd like to suggest an improvement to the property wrapper mechanism to help improve the readability of such use cases.

https://forums.swift.org/t/passing-custom-getter-and-setter-to-property-wrapper-initializer/32000

Pitch: Handling future cases of enums in libraries without binary stability concerns

I'd like to pitch a proposal that is basically SE-0192, but for library authors that don't care about binary stability.

I've complained about the problem earlier, and now I'd like to suggest a solution

Introduction

SE-0192 introduced a mechanism to add new cases to enums defined in the standard library and overlays in a source-compatible way. SE-0260 later lifted this restriction, allowing to use this mechanism in all libraries built in library evolution mode.

We propose to remove this restriction completely by:

  • allowing all library authors to mark their public enums as @frozen;
  • warning the clients that exhaustively switch over a non-frozen enum declared in another module, * suggesting them to add an @unknown default case.

https://forums.swift.org/t/pitch-handling-future-cases-of-enums-in-libraries-without-binary-stability-concerns/32026

Pitch: _property as fallback shortcut to self.property

The motivation is pretty much the same as SE-0009

That is, we need a shorter form of self.property that is more readable at the point of use.

The idea is:

Add fallback lookup for identifier starts with single _ (ex. _name), if the identifier is not a local variable , member property or global variable, then treat it as self.(identifier without _) (ex. self.name)

https://forums.swift.org/t/pitch-property-as-fallback-shortcut-to-self-property/32060

[Pre-Pitch] Whitespaces and punctuation for methods declarations

Swift has a beautiful concise yet expressive syntax.

When declaring testing methods, unfortunately, it may results in descriptive methods that are hard to read because of its lack of whitespace and punctuations.

I would like to pitch a proposal that adds support for a more natural language by allowing whitespaces and punctuation to methods declaration with a back-ticked syntax. As a usage example it would be something like:

func test object returns true when validation succeed ()

Instead of a less readable camel case equivalent:

func testObjectReturnsTrueWhenValidationSucceed()

https://forums.swift.org/t/pre-pitch-whitespaces-and-punctuation-for-methods-declarations/32073

Explictly capture variables in blocks

Introduction
We propose the explicit declaration of [strong someVar] the same way we declare [weak someVar] when capturing variables in a block scope.
If a "reference type variable" is captured in the block without explicitly declaring it as strong or weak the compiler produces a warning to alert the developer of an unintended strong capture of a "reference type variable".

https://forums.swift.org/t/explictly-capture-variables-in-blocks/32101

Swift benchmarks

I once a while check Swift benchmarks against other languages to see how the language is speeding.

Here is Swift vs Java

https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/swift.html

Why is Swift so awful in Regex and Binary Trees?

https://forums.swift.org/t/swift-benchmarks/32113/2

Google Client Libraries for server-server APIs

I'm a big fan of the swift programming language, and would love to use it on the server.
Coming from a lot of node.js/python/java programming, I always liked the client libraries that were provided by google, that made it seem easy to get up and running with any of the APIs.

However, since it's fairly new on the server, these client libraries don't exist for swift.
I think that this is a pretty big turn off for anyone wanting to try out swift on the server, the fact that they'll have to build web requests manually or build a library themselves.

I found that someone from google had started to make a basic implementation of auto-generating these APIs, so I decided to work on it further to make it more fit for purpose.
Have a look here: https://github.com/Mark-McCracken/google-api-swift-client 15

https://forums.swift.org/t/google-client-libraries-for-server-server-apis/32276

https://twitter.com/CodaFi_/status/1214442220255735808

This is a 15 second Instruments trace of the type checking operations being performed on the Swift Standard Library - rendered as a flame graph. https://twitter.com/CodaFi_/status/1214442220255735808/photo/1

+ thread

Another "finally..." option:

https://twitter.com/slava_pestov/status/1214632943953551361

Hey, it was an honest mistake! I was never a fan of access control anyway

“Scheduling a meeting in an inaccessible conference room” is some next-level trolling from your remote co-workers. Now I won’t be able to walk my own dog.

Development open for Swift 5.1.4 for Linux

We are happy to announce the opening of the development phase for Swift 5.1.4 for Linux with a planned release by the end of January 2020. The process for the dot-releases remains the same as for Swift 4.2.

https://forums.swift.org/t/development-open-for-swift-5-1-4-for-linux/32343

Adding a LinkedList type to the Standard Library

Swift is missing a great many data types (see Adding more data structures to the standard library). I thought I may be able to get this going with suggesting the introduction of a LinkedList type to Swift.

https://forums.swift.org/t/adding-a-linkedlist-type-to-the-standard-library/32339

SE-0274: Concise Magic File Names

The review of SE-0274 — Concise Magic File Names begins now and runs through January 16, 2020.

https://forums.swift.org/t/se-0274-concise-magic-file-names/32373

https://twitter.com/slava_pestov/status/1215126454767357959

It’s fun watching the expression checker folks work on this.

5.2 development branch: 3348
master: 2438

Less code in CSDiag.cpp => more failures handled by new diagnostics engine => fewer nonsense diagnostics presented to users https://twitter.com/slava_pestov/status/1170156759387955200

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

My little side project is coming in at 11x faster than the existing implementation for scanning the dependencies of a Swift file. https://github.com/apple/swift/pull/28515

That’s a dupe of mine above 😄

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

@cocoaphony Function builders don’t currently handle declarations. We’re literally in the middle of a refactoring/reimplementation of function builders to make that possible: https://github.com/apple/swift/pull/29133

Move Combine’s TopLevelEncoder and TopLevelDecoder protocols into the standard library

Combine introduced two Codable-related protocols to represent top level encoders and decoders. The TopLevelEncoder 4 is used to abstract JSONEncoder 1 and PropertyListEncoder for use in the encode(encoder:) operator. Decodable counterparts are also provided

https://forums.swift.org/t/move-combines-toplevelencoder-and-topleveldecoder-protocols-into-the-standard-library/32494

Interesting thread on Quora, we'll see if I add this.
https://www.quora.com/What-are-similarities-and-differences-between-C-and-Swift

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

Swift
_Resolved Issues_
Reduced the size of dependency files (.d) produced by the Swift compiler, which can improve incremental build times and disk usage for targets with many source files. (57361722, 57865813)

Resolved Issues
Inspection of global variables in Swift and Objective-C works properly in lldb. (57884467)

SE-0275: Allow more characters (like whitespaces and punctuations) for escaped identifiers

The review of SE-0275 — Allow more characters for escaped identifiers begins now and runs through January 20, 2020.

https://forums.swift.org/t/se-0275-allow-more-characters-like-whitespaces-and-punctuations-for-escaped-identifiers/32538

Dynamically-dispatched protocol extension members

A protocol's members may be either dynamically or statically dispatched, depending on how they are declared. Protocol requirements are dynamically dispatched, meaning that they resolve to conformance-specific implementations in generic code, whereas members defined in extensions are statically dispatched, meaning that they may not be overridden, and generic code will not use any such overrides even if they are available.

https://forums.swift.org/t/dynamically-dispatched-protocol-extension-members/32566

Tuples Conform to Equatable

Introduction
Introduce Equatable conformance for all tuples whose elements are themselves Equatable.

Swift-evolution thread: Tuples Conform to Equatable

This idea has been heavily discussed numerous times before with dozens of threads discussing this issue.

Motivation
Tuples in Swift currently lack the ability to conform to protocols. This has led many users to stop using tuples altogether in favor of structures that they can them conform protocols to. The shift from tuples to structures have made tuples almost feel like a second class type in the language because of them not being able to do simple operations that should just work.

https://forums.swift.org/t/tuples-conform-to-equatable/32559

Reciprocal operator

This is a very small pitch to add a new operator definition and implementation to the standard library:

prefix operator /
Its primary use case is to mean 1 / something. This would make swift operators more coherent, since the reciprocal is the multiplicative inversion operation, while the additive inversion operation is already implemented as the prefix minus. Also, it could be used to provide a default implementation of protocol requirements for division operations in terms of multiplying the lhs by the reciprocal of the rhs, which would be useful for things like numeric wrapper types.
Another use case that I had in mind is path is using it to construct path expressions like /"foo"/bar/"baz.swift".

https://forums.swift.org/t/reciprocal-operator/32611

https://twitter.com/jckarter/status/1217456947043028993

@nicklockwood You might also test again with a snapshot compiler. Swift 5.2’s ARC optimizer is massively improved over 5.1, which reduces both class retains and struct copies. If it manages to eliminate all ARC traffic now, the struct might end up ahead again

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jessesquires picture jessesquires  ·  9Comments

BasThomas picture BasThomas  ·  4Comments

jessesquires picture jessesquires  ·  6Comments

ColinEberhardt picture ColinEberhardt  ·  5Comments

jessesquires picture jessesquires  ·  6Comments