这个星期有很多激动人心的消息。别忘了 10 月 30 号还有 Apple Event 发布会,以及我们这一期全新的 Swift Unwrapped!Cool!
入门任务
- SR-8788 [Compiler] Rethrowing/convenience initializer does not compile
- SR-8811 [Compiler] Diagnosing Implicit Accessors for Uninhabited Types Should Be Smarter
- SR-8905 [Standard Library] Gaps in String benchmarking
- SR-8908 [Standard Library] Add
insert(_:Character)
benchmarks inRangeReplaceableCollection
Swift Unwrapped
Swift Unwrapped 第 67 期来了,Jesse 和 JP 讨论了 Swift 里的 Raw Strings。
社区新闻
FoundationDB 官方宣布支持 Swift 语言。
Jetbrains 家的 IDE - CLion 现在支持 Swift Package Manager 项目。
Ankit Aggarwal 写了一篇博客介绍 Swift Packages 现在支持 Read Evaluate Print Loop (REPL) !
Richard Wei 写了一份宣言介绍 Swift 语言设计里的第一类自动微分 (first-class automatic differentiation),这是为机器学习社区和 Swift 编程语言设计社区编写的,主要侧重于语言设计。
合并请求
Slava Pestov merged a pull request that fixes crashes and allows both spellings for protocols with where
clauses. If you would like to know more, see this thread.
Doug Gregor merged a pull request replacing associated type metadata accessors with mangled strings, bringing both code size and runtime performance improvements!
驳回提案
核心团队认为这对于语言来说是一个重要的补充,开发者能通过这样方便地运用 SIMD 技术。
关于这个提案,很大部分反馈是关于范型的语法:他们认为应该使用
Vector3<Int8>
而不是Int8.Vector3
。现在还不能决定哪一种方案孰优孰劣。但是,为了更好地做出决定,核心团队已要求提案作者实现原型,审核人员可以从而从实际实践中选出更好的方案。
另外,这份提案还应该更明确地描述具体细节,比如具体的掩码是怎么样的,它们分别有哪些作用。
审核中提案
SE-0231: Optional Iteration 正在审核中。
Optionals 是 Swift 中的一个关键特性。特别注意的是,它很好地表达了 act accordingly if there’s a value, skip otherwise 的理念。最常见的例子有:可选链(optional chaining),可选调用(optional invocation)如
foo?()
,if let
,可选模式(optional patterns),可选赋值(optional assignments)以及guard let
。这个提案计划在for-in
循环中进一步支持这种特性。
论坛动向
Argyrios Kyrtzidis 宣布 Language Service Protocol 现在支持 Swift 和 C-family 语言!
At Apple we are making it a priority to support high-quality tooling for all Swift developers, including those working on non-Apple platforms. We want to collaborate with the open-source community and focus our efforts on building common infrastructure that can be shared by Xcode and other editors and platforms.
To that end, I’m excited to announce that we are going to start a new open-source project for a Swift and C-family language service based on the Language Server Protocol. We’ve chosen to adopt LSP so we can benefit from its active community and wide adoption across other editors and platforms. This means that Visual Studio Code, Atom, Sublime Text, or whatever your favorite editor happens to be, can use the same service as Xcode, and any improvements we make to the service will benefit them all.
To add to what Ben mentioned, the new service will be written in Swift so it could use SwiftSyntax and any other functionality written on top of SwiftSyntax, like formatting.
Xi Ge 宣布现在可以使用 Swift 标准库的 ABI 稳定性检查器。
我们已经开始测试 Swift 标准库的 ABI 稳定性,以作为 Swift 回归测试的一部分。
[它]将检查改动是否破坏了之前基准的 ABI 稳定性。如果是,这会导致
stability-stdlib-abi.swift
的一个测试失败。为了使测试通过,我们通常可以更新stability-stdlib-abi.swift.expected
,或者更新改动来避免破坏稳定性。
Steve Canon 起草了一份提案关于浮点数类型的可比较性。
The
Comparable
andEquatable
protocols want to imply a total order. This is mostly satisfied byFloatingPoint
types, except for the behavior withNaN
s. A total order requires that for anya
andb
, eithera ≤ b
ora ≥ b
is true. But IEEE 754 requires that if eithera
orb
isNaN
, both of those comparisons are false.
尾声
如何撰写提案