<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 face="AvenirNext-Regular" class="">Hi Xiaodi,</font></div><div class=""><font face="AvenirNext-Regular" class=""><br class=""></font></div><div class=""><font face="AvenirNext-Regular" class="">that currently all members of a class or struct are exposed by default by having</font></div><div class=""><font face="AvenirNext-Regular" class="">a default scope of &nbsp;‘internal’ &nbsp;and are therefore accessible in the entire module</font></div><div class=""><font face="AvenirNext-Regular" class="">is imho very bad unstructured programming practice.&nbsp;</font></div><div class=""><font face="AvenirNext-Regular" class=""><br class=""></font></div><div class=""><font face="AvenirNext-Regular" class="">In no other OOP language it is implemented</font></div><div class=""><font face="AvenirNext-Regular" class="">that way..&nbsp;</font></div><div class=""><font face="AvenirNext-Regular" class=""><br class=""></font></div><div class=""><font face="AvenirNext-Regular" class="">from this Swift blog:</font></div><div class=""><a href="https://developer.apple.com/swift/blog/?id=5" class=""><font face="AvenirNext-Regular" class="">https://developer.apple.com/swift/blog/?id=5</font></a></div><div class=""><font face="AvenirNext-Regular" class=""><br class=""></font></div><div class=""><font face="AvenirNext-Regular" class="">i quote from this blog:</font></div><div class=""><font face="AvenirNext-Regular" class=""><br class=""></font></div><div class=""><font face="AvenirNext-Regular" class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">"By default, all entities have &nbsp;internal</span></font></span><span style="color: rgb(51, 51, 51); letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">&nbsp;access.&nbsp;</span></font></div><div class=""><span style="color: rgb(51, 51, 51); letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class=""><font face="AvenirNext-Regular" class="">This allows application developers to largely ignore access control,&nbsp;</font></span></div><div class=""><span style="color: rgb(51, 51, 51); letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class=""><font face="AvenirNext-Regular" class="">and most Swift code already written will continue to work without change."</font></span></div><div class=""><font face="AvenirNext-Regular" class=""><br class=""></font></div><div class=""><font face="AvenirNext-Regular" class="">Whoever wrote this, imho it is bad: especially this part:</font></div><div class=""><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">"This allows application developers to largely ignore access control”</span></font></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px;" class=""><br class=""></span></font></span></div><div class=""><span style="letter-spacing: -0.3570000231266022px; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255);" class=""><font face="AvenirNext-Regular" class="">To say the least, this not really a very well thought over sentence,&nbsp;</font></span></div><div class=""><span style="letter-spacing: -0.3570000231266022px; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255);" class=""><font face="AvenirNext-Regular" class="">which appears to me something&nbsp;</font></span><span style="font-family: AvenirNext-Regular; color: rgb(51, 51, 51); letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">like:&nbsp;</span></div><div class=""><span style="letter-spacing: -0.3570000231266022px; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255);" class=""><font face="AvenirNext-Regular" class="">“Hey yeah, it’s ok, just start coding like a blind horse,&nbsp;</font></span></div><div class=""><span style="letter-spacing: -0.3570000231266022px; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255);" class=""><font face="AvenirNext-Regular" class="">don’t worry about the details&nbsp;</font></span><span style="font-family: AvenirNext-Regular; color: rgb(51, 51, 51); letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">now. Care about it later. ”&nbsp;</span></div><div class=""><span style="color: rgb(51, 51, 51); letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class=""><font face="AvenirNext-Regular" class=""><br class=""></font></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">This is certainly not my idea of what is described as&nbsp;“Progressive Disclosure”&nbsp;</span></font></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">and encourages bad and unstructured programming. Students learn</span></font></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">undesirable habits&nbsp;</span></font></span><span style="letter-spacing: -0.3570000231266022px; color: rgb(51, 51, 51); font-family: AvenirNext-Regular; background-color: rgb(255, 255, 255);" class="">which, as with any habit, are hard to get rid off and</span></div><div class=""><span style="letter-spacing: -0.3570000231266022px; color: rgb(51, 51, 51); font-family: AvenirNext-Regular; background-color: rgb(255, 255, 255);" class="">can carry on throughout a large part of their career.&nbsp;</span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px;" class=""><br class=""></span></font></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">So, in this perspective, what is related to&nbsp;“Progressive Disclosure” should</span></font></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">be viewed with a grain of salt and due to the complexity of Swift its relevancy</span></font></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">is limited and should be approached with caution.&nbsp;</span></font></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px;" class=""><br class=""></span></font></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">True, in Swift , one can write in a very simple way, but this&nbsp;apparent&nbsp;triviality is&nbsp;</span></font></span></div><div class=""><font face="AvenirNext-Regular" class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">deceiving... To make&nbsp;</span></font></span><span style="letter-spacing: -0.3570000231266022px; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255);" class="">professional applications with Swift (or for that&nbsp;</span></font></div><div class=""><font face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255);" class="">matter in any other serious &nbsp;programming&nbsp;</span><span style="letter-spacing: -0.3570000231266022px; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255);" class="">language ) one should only</span></font></div><div class=""><font face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255);" class="">start making real apps equipped with a&nbsp;thorough&nbsp;understanding of the overall</span></font></div><div class=""><font face="AvenirNext-Regular" class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">language structure, its&nbsp;philosophy&nbsp;</span></font></span></font><span style="font-family: AvenirNext-Regular; color: rgb(51, 51, 51); letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">and environment, rather &nbsp;sooner than later.</span></div><div class=""><br class=""></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">That&nbsp;’s exactly where tutorials, courses, books, playgrounds etc. are meant for!</span></span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">There is a lot of very good&nbsp;material&nbsp;available, so there is really no obstacle</span></span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">to learn these fundamentals of the Swift language quite well before embarking&nbsp;</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">on creating&nbsp;</span></font><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255); color: rgb(51, 51, 51); font-family: AvenirNext-Regular;" class="">professional Swift apps.&nbsp;</span></div><div class=""><font face="AvenirNext-Regular" class=""><br class=""></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">Of course, one cannot (should not) define anything at all without knowing&nbsp;</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">about scope, access modifiers! &nbsp;Luckily, compared to other aspects of PLs,&nbsp;</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">understanding&nbsp;</span></font><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255); color: rgb(51, 51, 51); font-family: AvenirNext-Regular;" class="">scope of variables is almost trivial. Provided of course that</span></div><div class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255); color: rgb(51, 51, 51); font-family: AvenirNext-Regular;" class="">the scope mechanism&nbsp;</span><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255); color: rgb(51, 51, 51); font-family: AvenirNext-Regular;" class="">is natural&nbsp;</span><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255); color: rgb(51, 51, 51); font-family: AvenirNext-Regular;" class="">and orthogonal, unfortunately&nbsp;this is&nbsp;</span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">not the case in Swift,.</span></font></span></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="letter-spacing: -0.3570000231266022px;" class=""><br class=""></span></span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">Also in Swift there should be lexical scope only, I think, &nbsp;as in almost any other</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">procedural / OOP programming language. Swift is one of them.</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">This also eliminates the necessity of the keywords&nbsp;“private” and&nbsp;“fileprivate</span></span><span style="letter-spacing: -0.3570000231266022px;" class="">”</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">and makes the scope context easy to conceive , especially for</span></span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">beginning programmers. &nbsp;&nbsp;</span></span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class=""><br class=""></span></font></div><div class=""><br class=""></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">But it seems to be too late now to correct this deficiency (imho) in Swift I guess..</span></font></div><div class=""><br class=""></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">Concerning your *struct* example:</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">with correct lexical scope, it should then be written like this:&nbsp;</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class=""><br class=""></span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">struct PointOfView</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">{</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>public let x: Int &nbsp; &nbsp; &nbsp; &nbsp; // or any other applicable access modifier&nbsp;</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;public let y: Int</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class=""><br class=""></span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; public func distanceToPoint( p: PointOfView) -&gt; Double &nbsp; &nbsp;{. . .}&nbsp;</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; let pr: Int &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // private by default, not available outside this struct. &nbsp;</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; func Foo() { . . .} &nbsp; &nbsp; &nbsp;// &nbsp;private function &nbsp; &nbsp; &nbsp;&nbsp;</span></font></div><div class=""><span style="color: rgb(51, 51, 51); letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class=""><font face="AvenirNext-Regular" class="">}</font></span></div><div class=""><font face="AvenirNext-Regular" class=""><br class=""></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">As written before, for a class, one can add</span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="letter-spacing: -0.3570000231266022px;" class="">‘protected’&nbsp;&nbsp;items like so:</span></span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="background-color: rgb(255, 255, 255);" class=""><span style="letter-spacing: -0.3570000231266022px;" class=""><br class=""></span></span></font></div><div class=""><font color="#333333" face="AvenirNext-Regular" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp;protected var foo:Double &nbsp; // available to descendants (subclasses)</span></font></div><div class=""><font color="#333333" face="SF Pro Text, SF Pro Icons, Helvetica Neue, Helvetica, Arial, sans-serif" class=""><span style="font-size: 17px; letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class=""><br class=""></span></font></div><div class="">Kind Regards from a sunny <a href="http://www.speyer.de" class="">www.speyer.de</a></div><div class=""><font color="#333333" face="Avenir-Book" class=""><span style="letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class="">TedvG</span></font></div><div class=""><font face="Avenir-Book" class=""><span style="background-color: rgb(255, 255, 255);" class=""><a href="http://www.tedvg.com" class="">www.tedvg.com</a></span><span style="letter-spacing: -0.3570000231266022px; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255);" class="">&nbsp;</span></font></div></div><div class=""><span style="color: rgb(51, 51, 51); letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class=""><font face="Avenir-Book" class=""><br class=""></font></span></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 4. Apr 2017, at 01:44, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">The default access level is internal by default, not public. While there are good reasons to not make members public by default, it is important that members are internal by default.<br class=""><br class="">One important reason: progressive disclosure. Access modifiers make sense after you understand what encapsulation is all about. Encapsulation only really makes sense after you can actually write a type. If members are private by default, you cannot write a useful type without also learning access modifiers!<br class=""><br class="">Put another way:<br class=""><br class="">struct Point {<br class="">  let x: Int<br class="">  let y: Int<br class="">}<br class=""><br class="">...is by itself a useful type. If x and y were private, then this type would do nothing. Users would have to learn about access modifiers before they can write a useful type.<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, Apr 3, 2017 at 18:13 Ted F.A. van Gaalen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg">Hello,&nbsp;<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">(this is related to: &nbsp;<span style="font-family:Avenir-Medium" class="gmail_msg">&nbsp; &nbsp;Type-based ‘private’ access within a file)</span></div><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg">Currently class and struct items &nbsp;(variables, functions..) are public by default</div><div class="gmail_msg">that is, &nbsp;always accessible outside the class’s scope</div><div class="gmail_msg">for example: &nbsp;(Swift 3.1)&nbsp;</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(186,45,162)" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">class</span><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg">&nbsp;AsItIsNow</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg">{</font></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">private</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> a = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class="gmail_msg">10</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">private</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> b = </span><span style="font-variant-ligatures:no-common-ligatures;color:#272ad8" class="gmail_msg">12</span></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp;&nbsp; &nbsp;</span><br class="gmail_msg m_6063390315337117777webkit-block-placeholder"></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">func</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> aPlusB() -&gt; </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="gmail_msg">Int</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg">&nbsp; &nbsp; {</font></span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">return</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187" class="gmail_msg">a</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> + </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187" class="gmail_msg">b</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg">&nbsp; &nbsp; }</font></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">private</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">func</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp;helperFunction()</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg">&nbsp; &nbsp; {</font></span></div><div style="margin: 0px; line-height: normal; min-height: 21px;" class=""><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font face="Menlo" class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp;. . .&nbsp;</font></span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg">&nbsp; &nbsp; }</font></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><span style="font-size:small" class="gmail_msg">}</span></div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Having all items public by default has the following disadvantages:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">&nbsp; &nbsp;• All members are exposed by default, wether intended or not. This</div><div class="gmail_msg">&nbsp; &nbsp; &nbsp; could lead to class misusage unintended by the class’s creator.&nbsp;</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">&nbsp; &nbsp;• To prevent undesired access of functions vars etc. inside a class</div><div class="gmail_msg">&nbsp; &nbsp; &nbsp; one has to prefix often too many items with the ‘private’ access modifier keyword.</div><div class="gmail_msg"><div class="gmail_msg">&nbsp; &nbsp; &nbsp; Most of the functionality &nbsp;and items inside a class or struct are meant to&nbsp;</div><div class="gmail_msg">&nbsp; &nbsp; &nbsp; be used internally &nbsp;and should &nbsp;not be revealed to the outside world.&nbsp;</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">&nbsp; &nbsp;• It does not comply (contradicts) &nbsp;with lexical scope as in Swift functions etc.&nbsp;</div><div class="gmail_msg">&nbsp;&nbsp;</div><div class="gmail_msg">&nbsp; &nbsp;• It is frontally different to most other programming languages and</div><div class="gmail_msg">&nbsp; &nbsp; &nbsp;therefore confusing for those coming from C#, C++, Java, Pascal etc.&nbsp;</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I experience this as fundamentally wrong.&nbsp;</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Imho it should be as in the next example, everything in a class</div><div class="gmail_msg">is private by default. To access/deploy items from outside they&nbsp;</div><div class="gmail_msg">need to be defined with the ‘public’ access modifier,&nbsp;</div><div class="gmail_msg">not the other way around, please.&nbsp;</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(186,45,162)" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">class</span><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg">&nbsp;AsItShouldBeImho</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg">{</font></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:21px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp;a =&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class="gmail_msg">10 &nbsp;// private by default</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp;b =&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class="gmail_msg">12 &nbsp; // also</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:21px" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp;&nbsp; &nbsp;</span><br class="gmail_msg m_6063390315337117777webkit-block-placeholder"></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp;&nbsp;public&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">func</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp;aPlusB() -&gt;&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="gmail_msg">Int</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg">&nbsp; &nbsp;&nbsp;{</font></span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">return</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)" class="gmail_msg">a</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp;+&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)" class="gmail_msg">b</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg">&nbsp; &nbsp;&nbsp;}</font></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:21px" class="gmail_msg"><span style="font-size:small" class="gmail_msg">&nbsp; &nbsp;&nbsp;</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp;&nbsp;func private</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">Function() &nbsp;&nbsp;</span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg">&nbsp; &nbsp;&nbsp;{</font></span></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font size="2" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font face="Menlo" class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp;. . .&nbsp;</font></span></font></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg">&nbsp; &nbsp;&nbsp;}</font></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:21px" class="gmail_msg"><span style="font-size:small" class="gmail_msg">}</span></div></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:21px" class="gmail_msg"><span style="font-size:small" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">‘public’ &nbsp;could be an inferred attribute</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">for items defined with getters and setters..&nbsp;</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">or the compiler would demand public</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">for getters and setters..</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg"><br class="gmail_msg"></font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">The&nbsp;‘protected’&nbsp;keyword is needed.&nbsp;</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">‘protected’ would mean that the items are</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">accessible in subclasses &nbsp; (class only) &nbsp;</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg"><br class="gmail_msg"></font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">private items would also be inaccessible in</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">class extensions.&nbsp;</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg"><br class="gmail_msg"></font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">It is as yet unclear to me why it has not been done</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font size="2" class="gmail_msg"><font face="Avenir-Book" class="gmail_msg">like so from the beginning of Swift</font><font face="Avenir-Book" class="gmail_msg">…</font></font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg"><br class="gmail_msg"></font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">I’ve been lost in the eternal discussions over private access modifiers,</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">the volume of it makes me think that (either way in this discussions) the whole</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">scope definition is wrong in Swift .</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">especially using a file as scope limiter.&nbsp;</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">Imho there should be lexical scope only.</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">as in most other programming languages.</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">If done so correctly , one wouldn’t even need the&nbsp;‘private’&nbsp;keyword...</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg"><br class="gmail_msg"></font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">Kind Regards</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg">TedvG</font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg"><br class="gmail_msg"></font></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><a href="http://www.tedvg.com/" class="gmail_msg" target="_blank"><font face="Avenir-Book" size="2" class="gmail_msg">www.tedvg.com</font></a></div><div style="margin:0px;line-height:normal;min-height:21px" class="gmail_msg"><font face="Avenir-Book" size="2" class="gmail_msg"><a href="http://www.ravelnotes.com/" class="gmail_msg" target="_blank">www.ravelnotes.com</a></font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:21px" class="gmail_msg"><span style="font-size:small" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:21px" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:21px" class="gmail_msg"><span style="font-size:small" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:21px" class="gmail_msg"><span style="font-size:small" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:21px" class="gmail_msg"><span style="font-size:small" class="gmail_msg"><br class="gmail_msg"></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:21px" class="gmail_msg"><span style="font-size:small" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><font size="2" class="gmail_msg"><br class="gmail_msg"></font></span></div><div class="gmail_msg">&nbsp;</div><div class="gmail_msg"><br class="gmail_msg"></div></div></div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>
</div></blockquote></div><br class=""></body></html>