我在浏览 Swift模块标题时发现了这一点: protocol _ObjectiveCBridgeable { 同理: protocol _SequenceType { 来自Objective-C背景,这对我来说似乎非常传统.下划线_通常意味着相关实体是私有的,并且通常
protocol _ObjectiveCBridgeable {
同理:
protocol _SequenceType {
来自Objective-C背景,这对我来说似乎非常传统.下划线_通常意味着相关实体是私有的,并且通常在标题可见性方面隐藏.为什么在Swift中它们是公开可见的?是否为Swift更改了命名约定?
就Swift而言,似乎已经改变了惯例,如下所示:/// This protocol is an implementation detail of `SequenceType`; do /// not use it directly. /// /// Its requirements are inherited by `SequenceType` and thus must /// be satisfied by types conforming to that protocol. protocol _SequenceType { }
正如您所看到的,下划线_现在似乎暗示相关实体是其逻辑子项的“实现细节”.