<div dir="ltr">Indeed, I find it rather less convenient to write “fileprivate” in many places I previously would use “private”, and unfortunate that I must choose between aggregating many pieces into a single lengthy file or else polluting the module scope with implementation details.<div><br></div><div>I agree with Xiaodi that submodules are a far cleaner design, and I would very much like to replace “fileprivate” with a short word that implies “private to the submodule”. Then by default each file could be its own submodule, and a developer could opt into having more files in a submodule if they so desire.</div><div><br></div><div>Count me as opposed to any sort of “class scoped” access level.</div><div><br></div><div>Nevin</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 10, 2016 at 10:01 AM, Rien via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">&gt; On 10 Sep 2016, at 14:16, T.J. Usiyan via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; I am firmly against this. The 5 levels that we have cover us well and have enough complexity already.<br>
<br>
</span>Agree.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
&gt; On Sat, Sep 10, 2016 at 5:23 AM, Tom Bates via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt; I agree that classprivate would probably not work, maybe constructprivate? but then you are leaving our enum etc.<br>
&gt; With the `internal(class)` suggestion, if declaring a var such as `internal(set) var name: String?` would this become `internal(class, set) var name: String?`<br>
&gt; Also there would need to be some kind of compile check either way because if you declared an enum for example outside of a constructor you would not be able to mark it as our new constructor only access level or it would become inaccessible throughout the project.<br>
&gt;<br>
&gt; Re: submodules, they are indeed overkill for this. As you would need a separate submodule for each class you wanted to do this with and then run the risk of inter coupling lots of different really small submodules.<br>
&gt;<br>
&gt; Suggestions so far:<br>
&gt; `classprivate`<br>
&gt; `constructprivate`<br>
&gt; `private(instance)`, `private(instance, set)` - problem -&gt; how would this work? `public private(instance, set)`<br>
&gt; `internal(class)`<br>
&gt;<br>
&gt; Personally I think a name like `classprivate` or `constructprivate`, although not particularly well named would reduce complexities with private setters syntax and keep migrations much simpler.<br>
&gt;<br>
&gt;<br>
&gt; On Sat, 10 Sep 2016 at 07:09 Adrian Zubarev via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt; I don&#39;t think submodules would solve it nicely. Each module/submodule will require it&#39;s own namespace + it feels like an overkill to create submodules for a few types. `internal(xyz)` seems to me like a better solution. And yes this is purely additional and nothing for phase 1.<br>
&gt;<br>
&gt; --<br>
&gt; Adrian Zubarev<br>
&gt; Sent with Airmail<br>
&gt; Am 9. September 2016 um 19:09:12, Xiaodi Wu (<a href="mailto:xiaodi.wu@gmail.com">xiaodi.wu@gmail.com</a>) schrieb:<br>
&gt;<br>
&gt;&gt; Isn&#39;t the general solution to this problem submodules? In any case, seems like it&#39;d be out of scope for Swift 4 phase 1.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Fri, Sep 9, 2016 at 11:34 AM, Adrian Zubarev via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt; There must be a better solution to this problem, because you might also extend value types from different files. That would mean, we&#39;d need `structprivate` `protocolprivate` etc.<br>
&gt;&gt;<br>
&gt;&gt; How about: `internal(class)` etc. ? Or something like `internal(private)` to rule them all (I don&#39;t like the last name, but something that would rule them all would be nice to have)!<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Adrian Zubarev<br>
&gt;&gt; Sent with Airmail<br>
&gt;&gt; Am 9. September 2016 um 17:49:29, Tom Bates via swift-evolution (<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>) schrieb:<br>
&gt;&gt;<br>
&gt;&gt;&gt; There is currently no way of accessing &quot;shared code&quot; from extensions declared outside the base .swift file<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I would love to see along side the new fileprivate access level a classprivate access level that would allow any extension declared outside of the original .swift file to access these properties and functions in an attempt to reuse code.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; an example is below...<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; =================<br>
&gt;&gt;&gt; //MyClass.swift<br>
&gt;&gt;&gt; public class MyClass {<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; classprivate func sharedFunction() {<br>
&gt;&gt;&gt;   self.function1()<br>
&gt;&gt;&gt;   self.function2()<br>
&gt;&gt;&gt; }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; fileprivate func function1() {}<br>
&gt;&gt;&gt; fileprivate func function2() {}<br>
&gt;&gt;&gt; }<br>
&gt;&gt;&gt; =================<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; =================<br>
&gt;&gt;&gt; //MyClass+Save.swift<br>
&gt;&gt;&gt; extension MyClass {<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; public func save() {<br>
&gt;&gt;&gt;   self.someFunction()<br>
&gt;&gt;&gt;   self.sharedFunction()<br>
&gt;&gt;&gt; }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; fileprivate func someFunction() {}<br>
&gt;&gt;&gt; }<br>
&gt;&gt;&gt; =================<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Currently to achieve anything like this you would have to make the &quot;core&quot; functions public or internal or write the whole thing in a single file which as I understand it is not optimal for the compile speed and can get unmanageable for large classes. This would allow a more managed file structure and the separation of related functions from the core declaration.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; There would be no migration needed I don&#39;t think as the impact on current code would be zero until the developer adopts the new access level<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Regards,<br>
&gt;&gt;&gt; Tom<br>
&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt; swift-evolution mailing list<br>
&gt;&gt;&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt;&gt;&gt; <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>
&gt;&gt;<br>
&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt; swift-evolution mailing list<br>
&gt;&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt;&gt; <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>
&gt;&gt;<br>
&gt;&gt;<br>
&gt; ______________________________<wbr>_________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt; <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>
&gt;<br>
&gt; ______________________________<wbr>_________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt; <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>
&gt;<br>
&gt;<br>
&gt; ______________________________<wbr>_________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt; <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>
<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>
</div></div></blockquote></div><br></div>