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

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -