<div dir="ltr">Just to weigh in here, I too am enjoying Swift 3 greatly.<div><br></div><div>However, my experience with access modifiers is rather different. I am very glad that `internal` is the default: this reduces extraneous noise for the common case, and makes it really easy for new programmers to jump in.</div><div><br></div><div>Furthermore, I am beginning to think that changing the meaning of `private` and introducing `fileprivate` may not have been worth the complexity. Even with file-scope visibility, one must still use the full path to a member in order to use it: eg. MyClass.InnerStruct.specialFunction(), so the risk of collisions is minuscule.</div><div><br></div><div>Before the change, the only visibility scopes to consider were file, module, and everywhere. Now there can be nested private scopes, which may be “unutterable” in the sense that there is no way to declare a member in one scope with the same visibility as a private member of an outer scope.</div><div><br></div><div>When using the pattern whereby a type is built with many extensions in a single file, shared helper members must now be declared `fileprivate` whereas before they were simply `private`. I readily acknowledge that this is a *small* annoyance, but it is nevertheless that much extra typing and and that much extra noise.</div><div><br></div><div>I don’t expect that reverting such a major change would be worth the upheaval, especially since many people seem to like it, but I think there is value in the simpler model that we used to have.</div><div><br></div><div>In any event, I *do* think it would be worth renaming “fileprivate” to something shorter, if a suitable word can be found. I remember how much bikeshedding went on the first time around, including several people trying to find a better term than “fileprivate” without any luck, so it may well turn out that there just isn’t a suitable replacement.</div><div><br></div><div>If there is one though, count me on the side in favor of shortening “fileprivate”.</div><div><br></div><div>Nevin</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 26, 2016 at 3:58 PM, Ted F.A. van Gaalen 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"><div style="word-wrap:break-word"><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">Hello! Hope you are all OK! </font></span></div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">Using and converting To Swift 3.0 with many </font></span><font color="#0433ff"><span style="font-size:14px">advantages</span></font></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">and very little problems.</font></span><span style="color:rgb(4,51,255);font-size:14px">OK, thanks to all !</span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">also for the reasonably smart converter. Yes, yes, yes, I’m<br>still missing the classical for ;; loop (don’t wake me up <br>again plse :o)  but overall it is quite good!</font></span></div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><font color="#0433ff" style="font-size:14px">I also value the -finally correct- meaning of the scope qualifier “private” , thanks, </font></div><div style="margin:0px;line-height:normal"><font color="#0433ff" style="font-size:14px">which is as it should be (imho) inner scope restricting. </font></div><div style="margin:0px;line-height:normal"><font color="#0433ff" style="font-size:14px"><br></font></div><div style="margin:0px;line-height:normal"><font color="#0433ff" style="font-size:14px">As for “fileprivate”: as yet, I haven’t found a case</font></div><div style="margin:0px;line-height:normal"><font color="#0433ff" style="font-size:14px">where I should use “fileprivate” also because to me, the contents of</font></div><div style="margin:0px;line-height:normal"><font color="#0433ff" style="font-size:14px">a file should in principle not have anything to do with the entities</font></div><div style="margin:0px;line-height:normal"><font color="#0433ff" style="font-size:14px">contained in it, as a file should be just an data carrier. Therefore, </font></div><div style="margin:0px;line-height:normal"><font color="#0433ff" style="font-size:14px">it should have no effect to wether or not concatenate source.swift files</font></div><div style="margin:0px;line-height:normal"><font color="#0433ff" style="font-size:14px">into one big file for example, although I would not recommend this.</font></div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><font color="#0433ff" style="font-size:14px">As far as I can see without binoculars, the “fileprivate” acces modifier</font></div><div style="margin:0px;line-height:normal"><font color="#0433ff" style="font-size:14px">could be dropped, were it not for source compatibility reasons..<wbr>. </font></div><div style="margin:0px;line-height:normal"><font color="#0433ff" style="font-size:14px">  </font></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">Unless I am missing something: </font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">Still. something is not quite right yet, I think.</font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">Just like in a Swift function, I don’t want the inner elements</font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">of a class (or struct ?) to be visible in outer scope!</font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">This is the default case in most OOP languages. </font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">I fail to understand </font></span><span style="color:rgb(4,51,255);font-size:14px">why this is not so in Swift, please enlighten me. </span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff"><br></font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">As it is now, and as far as I know, I have to explicitly</font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">declare *all* entities inside a class that should not be accessible</font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">outside the class as private, like in this real-world example:  </font></span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><br></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><br></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span style="color:#ba2da2">class</span><span> TG3DGauge: </span><span style="color:#703daa">SCNNode</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>{</span></div><p style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;min-height:20px"><span>    </span><br></p><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    </span><span style="color:#ba2da2">private</span><span> </span><span style="color:#ba2da2">var</span><span> needles = [</span><span style="color:#703daa">SCNNode</span><span>]()</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    </span><span style="color:#ba2da2">private</span><span> </span><span style="color:#ba2da2">var</span><span> fmtStr = </span><span style="color:#d12f1b">“&quot; </span><span style="color:rgb(0,132,0)">// private should be the default imho.</span></div><p style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;min-height:20px">    </p><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    </span><span style="color:#ba2da2">var</span><span> value: </span><span style="color:#703daa">CGFloat</span><span> = </span><span style="color:#272ad8">0</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    {</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span style="color:#000000">        </span><span style="color:#ba2da2">didSet</span><span style="color:#000000">  </span>// trigger value change, rotate needles etc.</div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>        {</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>            </span><span style="color:#31595d">valueChange</span><span>()</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>        }</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    }</span></div><p style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;min-height:20px"><span>    </span><br></p><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    </span><span style="color:#ba2da2">private</span><span> </span><span style="color:#ba2da2">var</span><span> nodeUnitText = </span><span style="color:#703daa">SCNNode</span><span>()</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    </span><span style="color:#ba2da2">private</span><span> </span><span style="color:#ba2da2">var</span><span> nodeValueText = </span><span style="color:#703daa">SCNNode</span><span>()</span></div><p style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;min-height:20px"><span>    </span><br></p><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    </span><span style="color:#ba2da2">private</span><span> </span><span style="color:#ba2da2">var</span><span> valRange: </span><span style="color:#703daa">ClosedRange</span><span>&lt;</span><span style="color:#703daa">CGFloat</span><span>&gt; = (</span><span style="color:#272ad8">0</span><span>...</span><span style="color:#272ad8">100.0</span><span>)</span></div><p style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;min-height:20px"><span>    </span><br></p><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    </span><span style="color:#ba2da2">var</span><span> rangeNeedlesActive: </span><span style="color:#703daa">Bool</span><span> = </span><span style="color:#ba2da2">true</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    {</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>        </span><span style="color:#ba2da2">didSet</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>        {</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)"><span style="color:#000000">            </span><span>needles</span><span style="color:#000000">[</span><span style="color:#272ad8">2</span><span style="color:#000000">].</span><span style="color:#703daa">isHidden</span><span style="color:#000000"> = </span><span style="color:#3e1e81">!</span><span>rangeNeedlesActive</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)"><span style="color:#000000">            </span><span>needles</span><span style="color:#000000">[</span><span style="color:#272ad8">3</span><span style="color:#000000">].</span><span style="color:#703daa">isHidden</span><span style="color:#000000"> = </span><span style="color:#3e1e81">!</span><span>rangeNeedlesActive</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>        }</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    }</span></div><p style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;min-height:20px"><span>    </span><br></p><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    </span><span style="color:#ba2da2">private</span><span> </span><span style="color:#ba2da2">var</span><span> valScaleFactor: </span><span style="color:#703daa">CGFloat</span><span> = </span><span style="color:#272ad8">1</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span style="color:#272ad8"><br></span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span style="color:#272ad8"><span style="white-space:pre-wrap">        </span></span><span style="color:rgb(0,132,0)">// etc. more stuff</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><font color="#272ad8"><span style="white-space:pre-wrap">        </span>.</font></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><font color="#272ad8">        .</font></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><font color="#272ad8">} </font><span style="color:rgb(0,132,0)">// end class TG3DGauge</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span style="color:rgb(0,132,0)"><br></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><br></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">It should (imho) be the other way around: </font><span style="color:rgb(4,51,255)">that every member of </span></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><span style="color:rgb(4,51,255)">a class is private by default - that is invisible </span><span style="color:rgb(4,51,255)">outside the scope </span></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><span style="color:rgb(4,51,255)">were it is declared in.</span><span style="color:rgb(4,51,255)"> This was (and still is) the case with Objective C,</span></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><span style="color:rgb(4,51,255)">where </span><span style="color:rgb(4,51,255)">you need to explicitly</span><span style="color:rgb(4,51,255)"> declaring them in </span><span style="color:rgb(4,51,255)"> the  sourcefile.h file</span></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><span style="color:rgb(4,51,255)">to make them </span><span style="color:rgb(4,51,255)">visible and accessible in the outer scope</span><span style="color:rgb(4,51,255)"> </span></span></div><div style="margin:0px;line-height:normal"><span style="color:rgb(4,51,255);font-size:14px">Everything else, as existing in the sourcefile.m remains hidden, not visible</span></div><div style="margin:0px;line-height:normal"><span style="color:rgb(4,51,255);font-size:14px">in the outer scope.</span></div><div style="margin:0px;line-height:normal"><span style="color:rgb(4,51,255);font-size:14px"><br></span></div><div style="margin:0px;line-height:normal"><span style="color:rgb(4,51,255);font-size:14px">As a solution/suggestion and also to prevent the gruesome</span></div><div style="margin:0px;line-height:normal"><span style="color:rgb(4,51,255);font-size:14px">horror (did i already wrote something about that?  :o) of source breaking.</span></div><div style="margin:0px;line-height:normal"><font color="#0433ff" style="font-size:14px">I could think of the “closedscope” (or some other word) </font></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">access modifier, which states t</font><span style="color:rgb(4,51,255)">hat all things declared inside a class, </span></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><span style="color:rgb(4,51,255)">are private within the class </span><span style="color:rgb(4,51,255)">and thus invisible in the outer scope, unless</span></span></div><div style="margin:0px;line-height:normal"><font color="#0433ff"><span style="font-size:14px">preceeded with an overriding acces scope modifier like “public&quot;, “internal&quot; or &quot;fileprivate” </span></font></div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><br></div><p style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;min-height:20px"><span>    </span><br></p><div><span><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span style="color:rgb(186,45,162)">closedscope</span><span> </span><span style="color:rgb(186,45,162)">class</span><span> TG3DGauge: </span><span style="color:rgb(112,61,170)">S<wbr>CNNode</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>{</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;min-height:20px"><span>    </span><br></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    </span><span style="color:rgb(186,45,162)">var</span><span> needles = [</span><span style="color:rgb(112,61,170)">SCNNode</span><span>]()  </span><span style="color:rgb(0,132,0)">// is now private by default</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    </span><span style="color:rgb(186,45,162)">var</span><span> fmtStr = </span><span style="color:rgb(209,47,27)">“&quot;            </span><span style="color:rgb(0,132,0)">// is now private by default</span></div><p style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;min-height:20px">    <br></p><div style="margin:0px;line-height:normal"><span style="font-family:Menlo;font-size:17px">    </span><span style="font-family:Menlo;font-size:17px;color:rgb(186,45,162)">public var</span><span style="font-family:Menlo;font-size:17px"> value: </span><span style="font-family:Menlo;font-size:17px;color:rgb(112,61,170)">CGFloat</span><span style="font-family:Menlo;font-size:17px"> = </span><span style="font-family:Menlo;font-size:17px;color:rgb(39,42,216)">0 </span><font color="#008400" face="Menlo"><span style="font-size:17px">// Public!! visible outside class also for “fileprivate&quot; or “internal”  </span></font></div><div style="margin:0px;line-height:normal"><span style="font-family:Menlo;font-size:17px">   </span><span style="font-family:Menlo;font-size:17px"> </span><span style="font-family:Menlo;font-size:17px">{</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)">        </span><span style="color:rgb(186,45,162)">didSet</span><span style="color:rgb(0,0,0)">  </span><span>// trigger value change, rotate needles etc.</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>        {</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>            </span><span style="color:rgb(49,89,93)">valueChange</span><span>()</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>        }</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    }</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;min-height:20px"><span>    </span><br></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    </span><span style="color:rgb(186,45,162)">var</span><span> nodeUnitText = </span><span style="color:rgb(112,61,170)">SCNNode</span><span>()  </span><span style="color:rgb(0,132,0)">// is now private by default</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span>    </span><span style="color:rgb(186,45,162)">var</span><span> nodeValueText = </span><span style="color:rgb(112,61,170)">SCNNode</span><span>() </span><span style="color:rgb(0,132,0)">// is now private by default</span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span style="color:rgb(0,132,0)"><br></span></div><div style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo"><span style="color:rgb(0,132,0)">    //etc.</span></div><p style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;min-height:20px"><br></p><div style="margin:0px;line-height:normal"><font color="#0433ff"><span style="font-size:14px">This “closedscope&quot; modifier should only be effective for the current class, not its superclass(es),</span></font></div><div style="margin:0px;line-height:normal"><font color="#0433ff"><span style="font-size:14px">allowing one to hide/reveal entities in each class independently being part of the hierarchy.</span></font></div><div style="margin:0px;line-height:normal"><font color="#0433ff"><span style="font-size:14px">Also entities declared private should not be visible in descendant classes</span></font></div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><font color="#0433ff"><span style="font-size:14px">Also please note that I do miss the “protected” scope access modifier which allows entities to be exclusively</span></font></div><div style="margin:0px;line-height:normal"><font color="#0433ff"><span style="font-size:14px">visible to descendant classes, as in Java. Why not implement it in Swift as well?  </span></font></div><div style="margin:0px;line-height:normal"><font color="#0433ff"><span style="font-size:14px"><br></span></font></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">AFAICS:  All mentioned here would not be a source breaking. </font></span></div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">Opinions, remarks welcome.</font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff"><br></font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">met vriendelijke groeten</font></span></div><span class="HOEnZb"><font color="#888888"><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff">Ted</font></span></div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff"><br></font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff"><br></font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff"><br></font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff"><br></font></span></div><div style="margin:0px;line-height:normal"><span style="font-size:14px"><font color="#0433ff"><br></font></span></div><p style="margin:0px;font-size:17px;line-height:normal;font-family:Menlo;min-height:20px"><br></p></font></span></span></div></div><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>
<br></blockquote></div><br></div>