[swift-evolution] Swift evolution proposal: introduce typeprivate access control level

Jean-Daniel dev at xenonium.com
Thu Dec 1 01:40:31 CST 2016


> Le 30 nov. 2016 à 16:00, João David via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> Definetely the access control topic is highly contestable in the Swift scene but nevertheless I really strive for more flexibility in terms of how can I decouple and decompose my code arch among several source files.
> As an example, I reckon that the current approach of attributing properties with fileprivate is somehow encouraging developers to workaround patterns like "protected" accessors into padding files with endless classes hierarchies and that’s one of the main reasons why I’m agains’t this fileprivate access modifier in the first place.
> To sum up, I really strive for code with great encapsulation and this proposal is for sure marching in that direction.
> 
> If we can add extensibility to classes without break fundamental encapsulation rules while doing it in a organised way, without stuffing file sources with the whole class spectrum, we have a winner in my opinion.

If you add a typeprivate accessor,  it means you expose your internal details to all extensions and so breaks encapsulation.
It also means that anybody who want to access your private var will just have to write an extension to expose it.

> > Hello, everyone!
> > 
> > I would like to introduce a new proposal to swift evolution, but first I
> > would love to run it by all of you so I get everyone's feedback and enrich
> > it.
> > 
> > This proposal consists of introducing a new *typeprivate *access control
> > level which allows for members to be accessed in all extensions of a given
> > *type,* whether lying within or in another file.
> > 
> > You'll find the proposal draft in:
> > https://github.com/goncaloalvarez/swift-evolution/blob/master/ <https://github.com/goncaloalvarez/swift-evolution/blob/master/>
> > proposals/NNNN-introduce-typeprivate-access-control-level.md
> > 
> > Thanks in advance for taking the time to evaluate the proposal.
> > 
> > Best regards,
> > Gonçalo
> > 
> > 
> >  
> 
> João David
> iOS Software Architect
> LinkedIn <http://pt.linkedin.com/in/joaotdavid> | +351 933631927 | Skype: joaotdavid
> 
> Please visit the iSOPARC <http://ciafel.fade.up.pt/isoparc> and iSOFIT <http://ciafel.fade.up.pt/isofit> for iPad application website.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161201/7a8b2535/attachment-0001.html>


More information about the swift-evolution mailing list