SE-0261: Identifiable Protocol

As appealing as the flexibility is of the key path approach is, it's really a workaround for a missing language feature: the ability to nominate a differently-named function as the implementation of a protocol requirement.

This feature exists in underscored form as @_implements and has been used within the standard library in a couple of places in order to finalize the ABI. Ideally, this attribute could be productized and the underscore dropped. You would then write something like e.g.:

struct Person: Identifiable {
  @_implements(Identifiable, id)
  var socialSecurityNumber: String
  var name: String
}

Given the potential of this feature, we shouldn't bake into the ABI a workaround that could have negative performance and usability implications for the long term.

31 Likes