[swift-evolution] Simplifying Access Using 'Hidden'

Adrian Zubarev adrian.zubarev at devandartist.com
Mon Feb 13 10:21:03 CST 2017

People talk always like “I never liked fileprivate” and I feel like some of you forgot that fileprivate is not new to Swift. It’s the repainted private from days before Swift 3. I cannot recall anyone complaining about it that much. There were some people that forced the addition of a stricter private access modifier for Swift 3. Now that we have both, there are a lot of complains about fileprivate.

Adrian Zubarev
Sent with Airmail

Am 13. Februar 2017 um 17:10:45, Joanna Carter via swift-evolution (swift-evolution at swift.org) schrieb:

Le 13/02/2017 à 15:15, Adrian Zubarev via swift-evolution a écrit :  

> –1  
> I won’t even try to be constructive on this one. It simply makes me  
> tired of all this access modifier mess. |open|, |closed|, |public|,  
> |internal|, now |hidden|, |fileprivate|, |directoryprivate|,  
> |moduleprivate|, |private|, I might even forget some of the proposed  
> access modifiers.  
> Instead of adding new stuff that explodes the complexity we should put  
> our energy and fix existing issues, like the inconsistent |open| for  
> example.  

I would also say that access modifiers do seem to be be somewhat messy.  

I have never liked the idea of fileprivate ; this is the equivalent of Delphi's private scope, to which they then added strict private for class only scope. That was a similar mess.  

I am still not sure why we can't have the good old-fashioned visibilities of private, protected and public for classes. They have worked well for years and I feel we are changing things for change's sake.  

For all types other than classes, where inheritance is a feature, we have private, internal and public.  

For classes, we should definitely add protected ; I find internal just too exposing for stuff to be used exclusively by derived classes.  

But, I believe one of the motives behind fileprivate was to satisfy the need for extensions to a type to access private members.  

Just to put in my 2¢ worth, the only extra scope I would suggest could be named "extensible" and would allow anything so marked to be visible only as far as extensions ; the difference being that such extensions could then be placed in separate files.  

So, private, protected (class only), internal, public and extensible.  

Or is that too revolutionary ?  

swift-evolution mailing list
swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170213/122f7e61/attachment.html>

More information about the swift-evolution mailing list