[swift-evolution] [Review] SE-0026 Abstract classes and methods

Stephen Celis stephen.celis at gmail.com
Fri Feb 26 20:24:50 CST 2016

> On Feb 26, 2016, at 5:21 PM, David Scrève via swift-evolution <swift-evolution at swift.org> wrote:
> Actually, protocols and extensions cannot handle methods that requires attributes and data storage.
> So, by design, protocols and extensions can only be used to implement stateless interface where abstract classes are true classes with a state supported with attributes and properties.

This is true, but maybe that's the problem. A proposal for protocol and extension storage makes more sense to me.

> Abstract class can also enforce methods to be implemented and avoid misuse of default method implementation.

Protocols can enforce that methods are implemented. Protocol extensions can avoid misuse of the default method implementation.

> For example, NSOperation is a good candidat to abstract class because NSOperation itself is useless as a standalone class and should not be used as-it.  -(void)main should be made abstract because I don’t think NSOperation does not have any internal property and has default behavior.

NSBlockOperation (or something like it) can work on its own just fine.


More information about the swift-evolution mailing list