swift - Scope of a Type Name in Protocols -
i find myself hitting name space conflicts in type declarations. like:
protocol identifier : hashable {} // identifiable if has identifier protocol identifiable : hashable { typealias identifier : identifier // error: doesn't 'see' 'protocol identifier' var identifier : identifier { } } the simple solution define protocol identifiertype : hashable {} doesn't read right me. or in identifiable use typealias identifiertype : identifier types satisfying identifiable specialize on identifertype , doesn't read right me.
another case:
protocol food {} class foodservice <food : food> {} // error so naming convention should using? formulating relationship between 2 types incorrectly? there way express typealias identifier : global.identifier?
edit: responding comment -- if instead avoid typealias , tried:
protocol identifiable : hashable { var identifier : identifier { } } then compiler error of "protocol identifier can used generic constraint ..."
Comments
Post a Comment