Swift 4.1 正式发布,新增更多泛型特性支持

  Swift 4.1 兼容 4.0,并做了一些改进,其中大部分通过了 Swift Evolution 流程。此次发布,包含了对核心语言的更新,包括新增更多对泛型的支持、新的构建选项,以及对 Swift Package Manager 和 Foundation 框架的小改进。同时在 ABI 稳定(Application Binary Interface,应用程序二进制接口)方面也取得了重大进展,期待它真的能在 Swift 5 完全实现。

  语言更新:

  Swift 4.1 增加了更多的泛型特性,进一步推进 Swift Generics Manifesto 中提出的目标:

  SE-0143 Conditional Conformance

  SE-0157 Support recursive constraints on associated types

  SE-0185 Synthesizing Equatable and Hashable conformance

  SE-0187 Introduce Sequence.compactMap(_:)

  SE-0188 Make Standard Library Index Types Hashable

  SE-0191 Eliminate IndexDistance from Collection

  Foundation 更新:

  JSONEncoder 和 JSONDecoder 类现在支持在编码和解码期间转换密钥的新策略。

  ABI 稳定:

  在本地对象头部使用 word-size 字段进行引用计数 (SR-4353)

  通过 witness table 查看与枚举鉴别器的交互效率 (SR-4332)

  判断 existential 类型元数据的布局,包括协议描述符(SR-4341)

  定义通用和协议要求的规范化以实现与顺序无关的修改(SR-3733)

  审核每个运行时功能的可取性和行为(SR-3735)

  对 Sequences 和 Collections 施加适当的约束(SR-3453)

  使用条件一致性折叠各种集合 wrapper (SR-3458)

  其它更新:

  SE-0184 Unsafe[Mutable][Raw][Buffer]Pointer: add missing methods, adjust existing labels for clarity, and remove deallocation size

  SE-0186 Remove ownership keyword support in protocols

  SE-0189 Restrict Cross-module Struct Initializers

  SE-0198 Playground QuickLook API Revamp

  具体内容请查看发布公告。

  下载地址:https://swift.org/download/(编辑:雷林鹏 来源:网络)

原文地址:https://www.cnblogs.com/pengpeng1208/p/9582878.html