<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 ‘internal’ and are therefore accessible in the entire module</font></div><div class=""><font face="AvenirNext-Regular" class="">is imho very bad unstructured programming practice. </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.. </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 internal</span></font></span><span style="color: rgb(51, 51, 51); letter-spacing: -0.3570000231266022px; background-color: rgb(255, 255, 255);" class=""> access. </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, </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, </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 </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: </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, </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 </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. ” </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 “Progressive Disclosure” </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 </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. </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 “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. </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 apparent triviality is </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 </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 </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 programming </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 thorough 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 philosophy </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 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 ’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 material 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 </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 </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. </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 </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! Luckily, compared to other aspects of PLs, </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 </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 </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 </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 this is </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, 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 “private” and “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. </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: </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 // or any other applicable access modifier </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=""> 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=""> public func distanceToPoint( p: PointOfView) -> Double {. . .} </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=""> let pr: Int // private by default, not available outside this struct. </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=""> func Foo() { . . .} // private function </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’ 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=""> protected var foo:Double // 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=""> </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 <<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>> 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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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, <div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">(this is related to: <span style="font-family:Avenir-Medium" class="gmail_msg"> 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 (variables, functions..) are public by default</div><div class="gmail_msg">that is, always accessible outside the class’s scope</div><div class="gmail_msg">for example: (Swift 3.1) </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"> 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"> </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"> </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"> </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"> </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() -> </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"> {</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"> </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"> }</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"> </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"> 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"> {</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"> . . . </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"> }</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"> • All members are exposed by default, wether intended or not. This</div><div class="gmail_msg"> could lead to class misusage unintended by the class’s creator. </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"> • To prevent undesired access of functions vars etc. inside a class</div><div class="gmail_msg"> one has to prefix often too many items with the ‘private’ access modifier keyword.</div><div class="gmail_msg"><div class="gmail_msg"> Most of the functionality and items inside a class or struct are meant to </div><div class="gmail_msg"> be used internally and should not be revealed to the outside world. </div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"> • It does not comply (contradicts) with lexical scope as in Swift functions etc. </div><div class="gmail_msg"> </div><div class="gmail_msg"> • It is frontally different to most other programming languages and</div><div class="gmail_msg"> therefore confusing for those coming from C#, C++, Java, Pascal etc. </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I experience this as fundamentally wrong. </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 </div><div class="gmail_msg">need to be defined with the ‘public’ access modifier, </div><div class="gmail_msg">not the other way around, please. </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"> 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"> </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 // 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"> </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"> b = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class="gmail_msg">12 // 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"> </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"> public </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"> aPlusB() -> </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"> {</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"> </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"> </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"> + </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"> }</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 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"> func private</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">Function() </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;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"> . . . </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"> }</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’ 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.. </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 ‘protected’ keyword is needed. </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 (class 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"><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. </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. </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 ‘private’ 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"> </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>