> On Apr 6, 2016, at 11:09 PM, David Hart <[email protected]> wrote:
> 
> There's something I find very confusing with this proposal, and it's how Self 
> is already used in protocol definitions to represent the STATIC type of the 
> type that conforms to the protocol. I think people will be potentially very 
> confused by how Self represents different types in different contexts:
> 
> protocol Copyable {
>     func copy() -> Self
> }
> 
> class Animal : Copyable {
>     init() {}
>     func copy() -> Animal {
>         return Self.init()
>     }
> }
> 
> class Cat : Animal {}
> 
> In the previous sample, wouldn't it be confusing to people if Self in the 
> protocol means Animal in the Animal type, but Self in the Animal type may 
> mean Cat?

Protocol conformances are inherited, so that's not a valid conformance, and 
protocol Self is synonymous with class Self when a class conforms. 
Animal.copy() would have to return Self to conform to Copyable.

-Joe
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to