<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><font size="2" class="">Hello Joanna, seems you are quite new to programming, just kidding, so sad you</font>’<font size="2" class="">ve missed the punch card era,</font></div><div class=""><font size="2" class="">a lot of fun, but I cannot take you back there because my Delorean is broken :o)</font></div><div class=""><font size="2" class=""><br class=""></font></div><div class="">Seriously, t<span style="font-size: 13.714285850524902px;" class="">hank you for writing this, I share your opinion:</span></div><span style="font-size: 13.714285850524902px;" class=""><div class=""><span style="font-size: 13.714285850524902px;" class=""><br class=""></span></div></span><blockquote type="cite" class=""><span style="font-size: 13.714285850524902px;" class="">In the light of the preceding paragraphs, I would, respectfully, suggest that "protected" should be allowed for exclusive use in the case of classes that really have to derive from each other, but for no other reason.</span></blockquote>Exactly !<br class=""><blockquote type="cite" class=""><span style="font-size: 13.714285850524902px;" class=""> Likewise, "private" should mean what it has meant and still means in most other languages, members of classes only, since, like "protected", that is its true nature.</span><br style="font-size: 13.714285850524902px;" class=""></blockquote>Yes.<br class=""><blockquote type="cite" class=""><br style="font-size: 13.714285850524902px;" class=""><span style="font-size: 13.714285850524902px;" class="">What Swift presently calls "internal" seems to equate more to the C# concept of "internal" and, in my mind, needs no further discussion or change.</span><br style="font-size: 13.714285850524902px;" class=""><br style="font-size: 13.714285850524902px;" class=""><span style="font-size: 13.714285850524902px;" class="">Just as I was never happy with the Delphi concept of private and protected members being accessible, not just in the class or its derived types, but also from any code in the same code unit, I feel uneasy about the present definition of the private scope in Swift.</span><br style="font-size: 13.714285850524902px;" class=""><br style="font-size: 13.714285850524902px;" class=""></blockquote>Me too.<br class=""><blockquote type="cite" class=""><span style="font-size: 13.714285850524902px;" class="">I have seen some horrendous abuses of that privileged access, with the gradual growth of single code units to truly gargantuan proportions, just because someone felt that certain classes needed to violate all the rules of common sense and be able to access each others' private parts (if you'll pardon the vernacular).</span><br style="font-size: 13.714285850524902px;" class=""><br style="font-size: 13.714285850524902px;" class=""><br style="font-size: 13.714285850524902px;" class=""><br style="font-size: 13.714285850524902px;" class=""></blockquote>Especially this, couldn’t agree more:<br class=""><blockquote type="cite" class=""><span style="font-size: 13.714285850524902px;" class="">Personally, I would like to see the end of the file based scope and, instead, see more clearly defined "privileged" access between types, even if they are in the same code unit.</span><br style="font-size: 13.714285850524902px;" class=""></blockquote><br class=""><div class="">I would suggest the (true) use of “namespaces”, instead of file based scope,</div><div class="">so that entities &nbsp;*must* &nbsp;be imported or qualified by namespace.</div><div class=""><br class=""></div>When I started with Swift, i was under the false impression that Swift concatenates all the sources in a project and simply treat this<div class="">as one single source file…</div><div class=""><br class=""></div><div class="">To my knowledge there is no way to hide class members. This is not good !</div><div class="">I’d like to show how i prefer it in this example:&nbsp;</div><div class=""><br class=""></div><div class="">“private” here means: only visible within the scope where it was declared! &nbsp;Imho what private does now in Swift is</div><div class="">completely wrong.&nbsp;</div><div class="">“Protected” is here: like private but visible in descendants as well&nbsp;</div><div class=""><br class=""><div class=""><span style="font-family: Menlo; font-size: 16px; font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">namespace</span><span style="font-family: Menlo; font-size: 16px; font-variant-ligatures: no-common-ligatures;" class="">&nbsp;Eriador</span></div><div class="">{</div><div class=""><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">class</span><span style="font-variant-ligatures: no-common-ligatures" class=""> Mithril &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color: rgb(0, 132, 0);" class="">// This class is not visible outside the namespace.</span><span style="color: rgb(0, 132, 0); font-size: medium;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></div><div class=""><span style="font-family: Menlo; font-size: 16px; font-variant-ligatures: no-common-ligatures;" class="">{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="font-family: Menlo; font-size: 16px; font-variant-ligatures: no-common-ligatures; color: rgb(0, 132, 0);" class="">// a + b</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> a = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0.0</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; &nbsp;</span><span style="font-variant-ligatures: no-common-ligatures" class="">// should not visible outside this class/instance</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; private&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">var</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;b =&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1.0 &nbsp; &nbsp;// “private”is the default</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; public&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">var</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;c&nbsp;=&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1.0 &nbsp; &nbsp; // is visible outside the class</span></div><div style="text-align: start; margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="text-align: -webkit-center; font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">&nbsp; &nbsp; protected var d = “My precious…” &nbsp;// is also visible in descendants</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp;&nbsp;</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">init</span><span style="font-variant-ligatures: no-common-ligatures" class="">()</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; {</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; forgeRing()</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><p style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// to use this function outside, it should be preceeded</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// by a "public" keyword, like it is in Java:</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; public&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> stridingToMordor() -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; {</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">a</span><span style="font-variant-ligatures: no-common-ligatures" class=""> + </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">b + c</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span>}&nbsp;<span style="color: rgb(0, 132, 0);" class="">// end namespace Eriador</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class="">--------------------------------------------------------</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class="">//in another file</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class="">#import Foundation</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><br class=""></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class="">namespace Rohan</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span>{</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span>&nbsp; #import namespace Eradior</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class="">func quest()</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class="">&nbsp;{</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">&nbsp; &nbsp;var</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;mi&nbsp;=&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">Mithril</span><span style="font-variant-ligatures: no-common-ligatures;" class="">()</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp;<font color="#4f8187" class="">mi</font></span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">a</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">10.0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Error: &nbsp;“a" and “b" are&nbsp;</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">&nbsp; &nbsp;mi</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">b</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">10.0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// not public members of Aragorn &nbsp; &nbsp; &nbsp;</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">&nbsp; &nbsp;mi.c = 12345.67 &nbsp; &nbsp; &nbsp;// ok&nbsp;</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">&nbsp; &nbsp;print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ar</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span><span style="font-variant-ligatures: no-common-ligatures" class="">stridingToMordor</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">()) // ok</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp;}</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span>}</div></div></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><br class=""></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class="">Just my two cents to this ever lasting theme:</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class="">can’t see the wood for the trees anymore.</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class="">TedvG</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><br class=""></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><br class=""></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><br class=""></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><br class=""></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><br class=""></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""><br class=""></div></body></html>