<div dir="ltr">I don't like this at all and it comes down to "<span style="font-size:12.800000190734863px">what is hidden can also be unhidden</span>". This, to me, feels like it would create more confusion than it would address. Why not just use `internal` for `hidden` items? If we're ok with modifying import statements, why not simply have a command that imports `fileprivate` stuff? (not advocating for this).<div><br></div><div>I think that submodules would have really helped with this issue and it is unfortunate that we couldn't get them in for swift 3. </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 16, 2016 at 4:34 PM, Jonathan Hull via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I keep wanting a “protected” access level, but I must also admit that there was something really elegant about Swift 2’s access scheme (and I think most of us feel like the word ‘fileprivate’ feels out of place). I was thinking about how to mesh those two ideas, and I think I may have come up with a solution.<br>
<br>
I propose we replace ‘fileprivate’ with a new ‘hidden’ access level. Hidden would work exactly the same way as fileprivate does now, but adds the connotation that what is hidden can also be unhidden. By adding ‘import hidden TypeName’ to another file, that file also gains access to all of the hidden items of that type (kind of like if it was in the same file).<br>
<br>
#FileA<br>
import Foundation<br>
<br>
Struct A {<br>
private var x:Int<br>
hidden var y:Int //This is just like fileprivate, but can also be shared with other files<br>
}<br>
<br>
extension A {<br>
//y can be accessed here because they are in the same file<br>
}<br>
<br>
<br>
#FileB<br>
import Foundation<br>
import hidden A //This allows the entire file to see A’s hidden variables<br>
<br>
extension A {<br>
//y can be accessed here because of the ‘import hidden’ declaration<br>
}<br>
<br>
<br>
#FileC<br>
import Foundation<br>
<br>
extension A {<br>
//y can NOT be seen or accessed here because it is hidden<br>
}<br>
<br>
<br>
I think this is a fairly elegant solution to our protected dilemma, which also feels in sync with Swift 2’s file-based scheme. The key features:<br>
• Extensions no longer need to be piled in the same file if it is getting too long<br>
• Subclasses can be in their own file, but still have access to the necessary parts of their superclass<br>
• It communicates the author’s intent that the items are not meant to be visible to its users, but that it is expected to be used for extension/subclassing<br>
• It requires an explicit statement ‘import hidden’ to access the hidden variables. Safe by default, with override.<br>
• It is not bound by module boundaries (i.e. you could use it for subclassing classes from an imported module)<br>
• Roughly the same length as ‘private’ and ‘public’ so various declarations packed together are much easier to read (fileprivate breaks reading rhythm)<br>
<br>
Worth a formal proposal?<br>
<br>
Thanks,<br>
Jon<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</blockquote></div><br></div>