<div><br></div><div><br><div class="gmail_quote"><div>On Tue, 18 Apr 2017 at 04:56, Brent Royal-Gordon &lt;<a href="mailto:brent@architechies.com">brent@architechies.com</a>&gt; wrote:<br></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"><div><blockquote type="cite"><div>On Apr 15, 2017, at 2:01 AM, Manolo van Ee via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-3480126012150479644Apple-interchange-newline"><div><div><div class="gmail_quote"><div><span style="color:rgb(69,69,69);font-family:&#39;Helvetica Neue&#39;">Hi All,</span></div><div style="word-wrap:break-word"><div><div style="margin:0px;line-height:normal;font-family:&#39;Helvetica Neue&#39;;color:rgb(69,69,69);min-height:14px"><br></div><div style="margin:0px;line-height:normal;font-family:&#39;Helvetica Neue&#39;;color:rgb(69,69,69)">I’ve been following the access control discussion a little and I had an idea that I wanted to throw out here. I know it’s too late and the idea doesn’t provide source compatibility, but it seemed worthwhile to post it anyway. My apologies if something similar has already been proposed.</div><div style="margin:0px;line-height:normal;font-family:&#39;Helvetica Neue&#39;;color:rgb(69,69,69);min-height:14px"><br></div><div style="margin:0px;line-height:normal;font-family:&#39;Helvetica Neue&#39;;color:rgb(69,69,69)">First of all, I propose to use a trailing colon ‘:’ to make it clear that it’s an access control keyword. Secondly, the idea introduces new keywords that clearly describe the scope of access:</div><div style="margin:0px;line-height:normal;font-family:&#39;Helvetica Neue&#39;;color:rgb(69,69,69);min-height:14px"><br></div><div style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="Menlo" style="font-size:11px">scope:           (formerly private)</font></div><div style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="Menlo" style="font-size:11px">file:            (formerly fileprivate)</font></div><div style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="Menlo" style="font-size:11px">module:          (formerly internal, default)</font></div><div style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="Menlo" style="font-size:11px">extern:          (formerly public)</font></div><div style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="Menlo" style="font-size:11px">extern(open):    (formerly open)</font></div><div style="margin:0px;line-height:normal;font-family:&#39;Helvetica Neue&#39;;color:rgb(69,69,69);min-height:14px"><br></div><div style="margin:0px;line-height:normal;font-family:&#39;Helvetica Neue&#39;;color:rgb(69,69,69)">Examples:</div></div><div><ol class="m_-3480126012150479644m_6409612839568120956code-lines" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;line-height:1.6em;list-style:none;font-family:Helvetica,Arial,sans-serif"><li style="border-width:0px 0px 0px 18px;border-left-style:solid;border-left-color:transparent;margin:0px;outline:0px;padding:0px 10px 0px 0px;vertical-align:baseline;white-space:pre-wrap;list-style-type:none"><code class="m_-3480126012150479644m_6409612839568120956code-voice" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;font-family:Menlo,monospace;word-wrap:break-word;font-size:11px"><span class="m_-3480126012150479644m_6409612839568120956kt" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145)">extern:</span> <span class="m_-3480126012150479644m_6409612839568120956kt" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145)">class</span> <span class="m_-3480126012150479644m_6409612839568120956vc" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116)">SomePublicClass</span> {            <span class="m_-3480126012150479644m_6409612839568120956c" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,131,18)">// explicitly public class</span></code></li><li style="border-width:0px 0px 0px 18px;border-left-style:solid;border-left-color:transparent;margin:0px;outline:0px;padding:0px 10px 0px 0px;vertical-align:baseline;white-space:pre-wrap;list-style-type:none"><code class="m_-3480126012150479644m_6409612839568120956code-voice" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;font-family:Menlo,monospace;word-wrap:break-word;font-size:11px">    <span class="m_-3480126012150479644m_6409612839568120956kt" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145)">extern:</span> <span class="m_-3480126012150479644m_6409612839568120956kt" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145)">var</span> <span class="m_-3480126012150479644m_6409612839568120956vc" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116)">somePublicProperty</span> = <span class="m_-3480126012150479644m_6409612839568120956m" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(28,0,207)">0</span>     <span class="m_-3480126012150479644m_6409612839568120956c" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,131,18)">// explicitly public class member</span></code></li><li style="border-width:0px 0px 0px 18px;border-left-style:solid;border-left-color:transparent;margin:0px;outline:0px;padding:0px 10px 0px 0px;vertical-align:baseline;white-space:pre-wrap;list-style-type:none"><code class="m_-3480126012150479644m_6409612839568120956code-voice" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;font-family:Menlo,monospace;word-wrap:break-word;font-size:11px">    <span class="m_-3480126012150479644m_6409612839568120956kt" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145)">var</span> <span class="m_-3480126012150479644m_6409612839568120956vc" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116)">someInternalProperty</span> = <span class="m_-3480126012150479644m_6409612839568120956m" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(28,0,207)">0</span>           <span class="m_-3480126012150479644m_6409612839568120956c" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,131,18)">// implicitly internal class member</span></code></li><li style="border-width:0px 0px 0px 18px;border-left-style:solid;border-left-color:transparent;margin:0px;outline:0px;padding:0px 10px 0px 0px;vertical-align:baseline;white-space:pre-wrap;list-style-type:none"><code class="m_-3480126012150479644m_6409612839568120956code-voice" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;font-family:Menlo,monospace;word-wrap:break-word;font-size:11px">    <span class="m_-3480126012150479644m_6409612839568120956kt" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145)">file:</span> <span class="m_-3480126012150479644m_6409612839568120956kt" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145)">func</span> <span class="m_-3480126012150479644m_6409612839568120956vc" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116)">someFilePrivateMethod</span>() {}  <span class="m_-3480126012150479644m_6409612839568120956c" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,131,18)">// explicitly file-private class member</span></code></li><li style="border-width:0px 0px 0px 18px;border-left-style:solid;border-left-color:transparent;margin:0px;outline:0px;padding:0px 10px 0px 0px;vertical-align:baseline;white-space:pre-wrap;list-style-type:none"><code class="m_-3480126012150479644m_6409612839568120956code-voice" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;font-family:Menlo,monospace;word-wrap:break-word;font-size:11px">    <span class="m_-3480126012150479644m_6409612839568120956kt" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145)">scope:</span> <span class="m_-3480126012150479644m_6409612839568120956kt" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145)">func</span> <span class="m_-3480126012150479644m_6409612839568120956vc" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116)">somePrivateMethod</span>() {}     <span class="m_-3480126012150479644m_6409612839568120956c" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,131,18)">// explicitly private class member</span></code></li><li style="border-width:0px 0px 0px 18px;border-left-style:solid;border-left-color:transparent;margin:0px;outline:0px;padding:0px 10px 0px 0px;vertical-align:baseline;white-space:pre-wrap;list-style-type:none"><code class="m_-3480126012150479644m_6409612839568120956code-voice" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;font-family:Menlo,monospace;word-wrap:break-word;font-size:11px">}</code></li></ol><div><span style="font-size:11px"><br></span></div></div><div><ol class="m_-3480126012150479644m_6409612839568120956code-lines" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;line-height:1.6em;list-style:none;font-family:Helvetica,Arial,sans-serif"><li style="border-width:0px 0px 0px 18px;border-left-style:solid;border-left-color:transparent;margin:0px;outline:0px;padding:0px 10px 0px 0px;vertical-align:baseline;white-space:pre-wrap;list-style-type:none"><code class="m_-3480126012150479644m_6409612839568120956code-voice" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;font-family:Menlo,monospace;word-wrap:break-word;font-size:11px"><span class="m_-3480126012150479644m_6409612839568120956kt" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145)">extern(open):</span> <span class="m_-3480126012150479644m_6409612839568120956kt" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145)">class</span> <span class="m_-3480126012150479644m_6409612839568120956vc" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116)">SomeOpenClass</span> {        <span class="m_-3480126012150479644m_6409612839568120956c" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,131,18)">// explicitly open class</span></code></li><li></li></ol></div><div><ol class="m_-3480126012150479644m_6409612839568120956code-lines" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;line-height:1.6em;list-style:none;font-family:Helvetica,Arial,sans-serif"><li style="border-width:0px 0px 0px 18px;border-left-style:solid;border-left-color:transparent;margin:0px;outline:0px;padding:0px 10px 0px 0px;vertical-align:baseline;white-space:pre-wrap;list-style-type:none"><code class="m_-3480126012150479644m_6409612839568120956code-voice" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;font-family:Menlo,monospace;word-wrap:break-word;font-size:11px">    <span class="m_-3480126012150479644m_6409612839568120956kt" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145)">extern(open):</span> <span class="m_-3480126012150479644m_6409612839568120956kt" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145)">func</span> <span class="m_-3480126012150479644m_6409612839568120956vc" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116)">someOpenMethod</span>() {} <span class="m_-3480126012150479644m_6409612839568120956c" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,131,18)">// explicitly open class member</span></code></li><li style="border-width:0px 0px 0px 18px;border-left-style:solid;border-left-color:transparent;margin:0px;outline:0px;padding:0px 10px 0px 0px;vertical-align:baseline;white-space:pre-wrap;list-style-type:none"><code class="m_-3480126012150479644m_6409612839568120956code-voice" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;font-family:Menlo,monospace;word-wrap:break-word;font-size:11px">}</code></li></ol><div><br></div></div><div><div style="margin:0px;line-height:normal;font-family:&#39;Helvetica Neue&#39;;color:rgb(69,69,69)">Having the keyword describe the access scope actually fits the access control model of Swift very well. The user doesn’t have to learn what public or private means, but only needs to know the concept. Especially coming from another programming language I think public and private are confusing and breaking with it will signal very clearly that the Swift model is different.</div><div style="margin:0px;line-height:normal;font-family:&#39;Helvetica Neue&#39;;color:rgb(69,69,69);min-height:14px"><br></div></div><div style="margin:0px;line-height:normal;font-family:&#39;Helvetica Neue&#39;;color:rgb(69,69,69);min-height:14px"><div style="margin:0px;line-height:normal">The idea is source breaking, but it’s very easy to deprecate the current syntax with a warning and automatically migrate, because:</div>
<ul>
<li style="margin:0px;line-height:normal">All keywords are redefined, so there can be no confusion with the current syntax.</li>
<li style="margin:0px;line-height:normal">Only redefines the syntax, not the semantics.</li></ul><div><br></div><div>Funny thing, I thought of this last night and when I woke up this morning I read Erica’s proposal that uses many of the same keywords, although in a different way. Telepathy? Or maybe we’re just onto something here?</div><div><br></div><div>I know this will turn everything upside down, but I like the overall consistency, so I just wanted to throw it into the group as the next idea to fix access controls and see if anyone likes it.</div><div><br></div><div>Alternatives considered:</div><ul>
<li style="margin:0px;line-height:normal">‘all’ instead of ‘extern’. This sounds to me as if it can always be accessed from everywhere, which might not be what we want if we introduce submodules.</li></ul></div></div></div></div></div></blockquote><br></div></div><div style="word-wrap:break-word"><div>Approaches like this were evaluated and rejected even before we introduced strict source stability requirements. `extern(open)` undoes an important feature of the `public`/`open` design, which is that there&#39;s no syntactic penalty for opening a symbol. And the SE-0169 acceptance specifically stated there would be no more access control changes in Swift 4.</div><div><br></div><div>I don&#39;t think this is a viable suggestion.</div></div><div style="word-wrap:break-word"><br><div>
<span class="m_-3480126012150479644Apple-style-span" style="border-collapse:separate;font-variant-ligatures:normal;font-variant-east-asian:normal;line-height:normal;border-spacing:0px"><div><div style="font-size:12px">-- </div><div style="font-size:12px">Brent Royal-Gordon</div></div></span></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span class="m_-3480126012150479644Apple-style-span" style="border-collapse:separate;font-variant-ligatures:normal;font-variant-east-asian:normal;line-height:normal;border-spacing:0px"><div><div style="font-size:12px">Architechies</div></div></span></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br></div></blockquote></div></div><div>I wasn&#39;t happy about &#39;extern(open)&#39; either, but I liked the overall consistency of the concept (at least for the other keywords) and hoped it could be improved somehow.</div><div><br></div><div>Anyway, thanks for your response and sorry for the noise.</div><div><br></div><div>Regards,</div><div>Manolo</div><div><br></div><div><br></div><div><br></div>