[swift-evolution] [swift-evolution-announce] [Review #2] SE-0117: Default classes to be non-subclassable publicly

Karl Wagner razielim at gmail.com
Sun Jul 17 09:29:56 CDT 2016


 
 
  As an alternative to having `open` as a separate access level, we could instead have it merely imply `public`: the canonical form would be `public open`, but source code could just say `open`. Generated interfaces would always say `public open`, so searching for `public` in those would work as you want it to.
 
 
 
 
 
I would not support this. Open and public are orthogonal concepts, just like final and public are today.
 

 
Just because your internal implementation details involve classes and subclasses, you shouldn't have to expose that to the whole world.
 

 
I think it should be an attribute/qualifier on the access level (similar to mutability for properties). You may wish to allow internal subclassing while preventing external subclassing (e.g. The API isn't stable yet, you're thinking of opening it publicly later but you want to refine it through internal usage first).
 

 
Or, as I mentioned before, perhaps you are forced to return an "abstract" class because we don't have sealed protocols.
 

 
These are all decisions for the API author, and by having the openness scopes to access level we give them ultimate flexibility to annotate which parts of their API can be replaced and by whom.
 

 
Karl
 
 
 
>  
>  
>  
>
>        
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160717/b5f05898/attachment.html>


More information about the swift-evolution mailing list