[swift-evolution] [Proposal] Sealed classes by default

Matthew Johnson matthew at anandabits.com
Wed Jun 29 18:06:55 CDT 2016


> On Jun 29, 2016, at 6:05 PM, David Sweeris via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> 
> Sent from my iPhone
> 
>> On Jun 29, 2016, at 17:45, Rod Brown via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> From my understanding, "Sealed" or whatever we will call it technically provides no actual optimisations. We cannot assume the class is final because something inside the module may have vended a subclass.
> 
> Sure we can. Because the class is sealed, the compiler can know that no further subclassing is possible, which can allowing it to use static dispatch, inlining, etc wherever possible.

The compiler knows that subclasses cannot happen outside the module, but if subclasses exist within the module there will be many cases where the compiler won’t be able to devirtualize.

> 
> I think...
> 
> - Dave Sweeris
> _______________________________________________
> 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