[swift-evolution] Final by default for classes and methods
Craig Cruden
ccruden at novafore.com
Wed Dec 23 14:49:48 CST 2015
Not sure how feel about sealing or final as a default - no strong feelings other than if it is that we should split the baby and go with sealed…. so “outside” code cannot extend it…. but for the most part I don’t have strong opinions.
I agree with Brent that inheritance is overused and really should be more limited in it’s usage. Inheritance is more fragile and composition and protocols should be preferred over inheritance.
> On 2015-12-24, at 3:43:27, Matthew Johnson via swift-evolution <swift-evolution at swift.org> wrote:
>
>
>
> Sent from my iPhone
>
> On Dec 23, 2015, at 2:35 PM, Brent Royal-Gordon <brent at architechies.com> wrote:
>
>>> If the frameworks are written in Swift, nothing is stopping Apple from slapping 'final' on all the classes they don't want developers to inherit from, even if the proposal is rejected; neither is there anything stopping them from making all their classes inheritable (if that happened to be what they wanted, which it isn't).
>>
>> You cannot look at a language simply as a technical artifact. A language creates culture and shapes the systems written in it. It defines not only what is possible and what is not, but also what is preferred and what is discouraged. Defaults matter. If they didn't, people wouldn't be trying to change the default.
>>
>
> Agreed.
>
>> Making `final` the default, or `sealed` the default, encourages the use of closed class hierarchies. It attempts to make inflexibility the preferred form of shared Swift code. I'm not sure that's the right thing to do.
>>
>
> I don't agree with this framing. IMO it encourages alternative designs emphasizing protocols and composition. This is a very good thing IMHO. I like to think of inheritance is a tool is last resort.
>
> BTW, I am planning a future proposal regarding automatic forwarding which if accepted would make the use of protocols and composition more convenient.
>
>> --
>> Brent Royal-Gordon
>> Architechies
>>
> _______________________________________________
> 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