[swift-evolution] [Draft] Allow declaration of abstract functions and properties on classes

Developer devteam.codafi at gmail.com
Mon Feb 29 10:44:47 CST 2016


You can write class-only protocols in Swift.

~Robert Widmann

2016/02/29 11:27、Evan Maloney via swift-evolution <swift-evolution at swift.org> のメッセージ:

>> I would still rather have a solution that extends protocols than one that relies specifically on classes, it seems to me that doing so would make the resulting functionality more generic (for instance, it might be possible to use it with structs as well as classes). However, I’m starting to agree that this is an important language feature indeed, since I can’t think of any better (or even equivalent) way of solving the example you showed.
> 
> I'm not sure I understand the desire to make protocols fulfill the role of an abstract class. They're entirely orthogonal concepts.
> 
> Protocols are designed to work just as well with structs, enums or classes. Of those, structs and enums have no concept of an inheritance hierarchy. So, the concept of an abstract class is only relevant in one of the three places where a protocol might be used.
> 
> It seems to me it would make sense to limit the 'abstract' concept to just classes, and not have the concept leak through to other things where is may not be relevant (i.e. protocols) and where it definitely wouldn't be relevant (structs and enums).
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list