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


(Thorsten Seitz) #1

Proposal link:

https://github.com/apple/swift-evolution/blob/master/proposals/0026-abstract-classes-and-methods.md

• What is your evaluation of the proposal?

+1 but with the addition of a “protected” scope because for me the most important use case of abstract methods would be template methods where the method to be customized should not be part of the public interface. It has to be declared, though, so that the template method can reference it.

This is not possible with protocols, because all members of a protocol must have the same access scope as the protocol itself. Actually I’d like this to change in the future, so that e.g. the “protected” scope I’m proposing as extension to the current proposal would be usable in protocols as well. But this does not invalidate the need for abstract classes, because I think that as long as classes define types they should offer similar tools as protocols and not be second class citizens.

Actually I think that the separation between protocols and classes is historical baggage in the first place and there should be only classes with real multiple inheritance which would put the discussion of POP vs. OOP at rest (I recently wrote a lengthy post on the Mixin thread discussing that: http://article.gmane.org/gmane.comp.lang.swift.evolution/8362).

• Is the problem being addressed significant enough to warrant a change to Swift?

Yes, template methods are a powerful tool in the design toolbox and should be supported by the language.

This requires abstract methods in combination with a “protected” scope.

• Does this proposal fit well with the feel and direction of Swift?

Yes. While Swift leans heavily on protocols (“POP”), classes still have their place and define types just as protocols do, so they shouldn’t be just second class citizens but do what they do well.

• If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?

Java, C++, Ceylon, Scala, Eiffel all have abstract classes. They all have access scopes similar to “protected” to enable full use of abstract methods.

• How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

In-depth study. I took part in the discussion, as well.

-Thorsten