<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Great summary, but I would still use new keywords rather than adding modifiers to private itself.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">public</div><div id="AppleMailSignature">module</div><div id="AppleMailSignature">file/ sourceFile /pick a better word :)</div><div id="AppleMailSignature">private<br><br>Sent from my iPhone</div><div><br>On 16 Mar 2016, at 06:49, Patrick Pijnappel via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><p style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="arial, helvetica, sans-serif">Ok to summarize:</font></p><p style="margin:0px;line-height:normal;color:rgb(69,69,69)"><br></p><p style="margin:0px;line-height:normal;color:rgb(69,69,69)"><b>Setter access modifiers</b></p><p style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="monospace, monospace">var foo: Int { private set { ... } }</font></p><p style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="monospace, monospace">var foo: Int { private set }</font></p>
<ul>
<li style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="arial, helvetica, sans-serif">Consistent with </font><font face="monospace, monospace">mutating set { ... }</font><font face="arial, helvetica, sans-serif">. Arguably the current </font><font face="monospace, monospace">private(set)</font><font face="arial, helvetica, sans-serif"> is inconsistent.</font></li>
<li style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="arial, helvetica, sans-serif">Eliminates the odd corner case of having a double access modifier, e.g. </font><font face="monospace, monospace">public private(set) var foo: Int</font><font face="arial, helvetica, sans-serif">.</font></li>
<li style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="arial, helvetica, sans-serif">It's very sensible for custom getters/setters (top case), it just requires allowing a bodiless get/set. We already kinda do this in protocols.</font></li></ul><div><font color="#454545" face="arial, helvetica, sans-serif"><br></font></div><div><font color="#454545" face="arial, helvetica, sans-serif"><b>Access modifier keywords</b></font></div>
<p style="margin:0px;line-height:normal;color:rgb(69,69,69)"><span style="font-family:monospace,monospace">public/</span><span style="font-family:monospace,monospace">private(module)/</span><span style="font-family:monospace,monospace">private(file)/</span><span style="font-family:monospace,monospace">private</span><br></p>
<ul>
<li style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="arial, helvetica, sans-serif">It's not clear from the keywords how restrictive </font><font face="monospace, monospace">local/private/internal</font><font face="arial, helvetica, sans-serif"> are, while </font><font face="monospace, monospace">private(module)</font><font face="arial, helvetica, sans-serif"> and </font><font face="monospace, monospace">private(file)</font><font face="arial, helvetica, sans-serif"> are obvious. This makes a</font><font face="arial, helvetica, sans-serif"> declaration either </font><font face="monospace, monospace">public</font><font face="arial, helvetica, sans-serif">, or </font><font face="monospace, monospace">private</font><font face="arial, helvetica, sans-serif"> to a certain scope. Arguably e.g. </font><font face="monospace, monospace">public/module/file/declaration</font><font face="arial, helvetica, sans-serif"> has similar benefits but they aren't as clearly access control related as a keyword (e.g. </font><font face="monospace, monospace">module</font><font face="arial, helvetica, sans-serif"> could just as well be declaring a module).</font></li>
<li style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="monospace, monospace">private(module)</font><font face="arial, helvetica, sans-serif"> and </font><font face="monospace, monospace">private(file)</font><font face="arial, helvetica, sans-serif"> are relatively long, but the longest – </font><font face="monospace, monospace">private(module)</font><font face="arial, helvetica, sans-serif"> – is rarely used (outside the standard library) as it's the default. Most uses of the old </font><font face="monospace, monospace">private</font><font face="arial, helvetica, sans-serif"> are more appropriately done using the new </font><font face="monospace, monospace">private</font><font face="arial, helvetica, sans-serif">, so </font><font face="monospace, monospace">private(file)</font><font face="arial, helvetica, sans-serif"> would likely be used less than </font><font face="monospace, monospace">private</font><font face="arial, helvetica, sans-serif">. </font></li>
<li style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="arial, helvetica, sans-serif">The scheme expands very well to named submodules, e.g. if you have a submodule named </font><font face="monospace, monospace">model</font><font face="arial, helvetica, sans-serif"> </font><font face="arial, helvetica, sans-serif">you might limit the scope using </font><font face="monospace, monospace">private(model)</font><font face="arial, helvetica, sans-serif">. </font></li><li style="margin:0px;line-height:normal;color:rgb(69,69,69)"><font face="monospace, monospace">private(file)</font><font face="arial, helvetica, sans-serif"> as opposed to </font><font face="monospace, monospace">private-file</font><font face="arial, helvetica, sans-serif"> or </font><font face="monospace, monospace">private/file</font><font face="arial, helvetica, sans-serif"> makes it more consistent with the new function-like syntax for e.g. attributes.</font></li>
</ul></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 16, 2016 at 11:26 AM, Ross O'Brien via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It's occurring to me, reading these recent posts, that we have two orthogonal systems of access levels.<div><br></div><div>Swift's current access system is file based; a project file decides which files comprise a module, and the terms 'public', 'internal' and 'private' determine whether a property is accessible to all, accessible only within files of the module, or accessible only within a file. (This takes on an extra dimension as files may belong to several modules).<div><br></div><div>The concept which began this discussion, and several of the proposed concepts in this discussion, ask instead for a type-based access system similar to those in other languages including Objective-C, where 'public', 'protected' and 'private' are the terms of choice and they restrict access to a type or subtypes.</div><div><br></div><div>I think it would be confusing if Swift applied 'public' to a concept in the file-based access system and 'private' to a concept in the type-based access system.</div><div><br></div><div>I would prefer clearer terms which actually mention the restrictions of the level. For example, 'inherited', not 'protected', in the case of properties accessible by a class and its subclasses; 'declaration', rather than 'private' or 'scoped', to refer to properties only accessible within a given type or extension declaration.</div><div><br></div><div>Since, at the moment, a declaration can only occur within one file, I think this most-restricted level has managed to pass as a level of the file-based access system. However, if the system is ever extended, we're going to run into new syntax decisions where we have 'private module' functions (accessible only within the given type in the same module) trying to communicate with 'protected file' properties (accessible only with the type and its subtypes in the same file), and that might lead to conflicts, so perhaps we should decide how those might be declared now.</div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 15, 2016 at 11:51 PM, Jonathan Hull via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span><div><pre style="white-space:pre-wrap;background-color:rgb(255,255,255)"><pre style="white-space:pre-wrap">On Tue, Mar 15, 2016 at 2:33 PM Erica Sadun <<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">erica at ericasadun.com</a>> wrote:</pre><div><blockquote type="cite"><pre style="white-space:pre-wrap">And again, moving the access control modification to the end just doesn't look
right to me or seem to enhance readability. :(</pre></blockquote></div></pre></div></span>I like Shawn’s proposal better for cases where there are custom getter/setter implementations. We should definitely be able to do:<div><br></div><div>var foo:Int {</div><div><span style="white-space:pre-wrap">        </span>public get {…}</div><div><span style="white-space:pre-wrap">        </span>private(file) set {…}</div><div>}</div><div><br></div><div>In fact, that is what I first tried to do before learning about private(set). But without the implementations, it just seems strange to put the scoping after the rest of the declaration (they work above because they are <i>before</i> the custom getter/setter).</div><div><br></div><div>I still like the idea of having the option to use parameter-like syntax for cases where you don’t have custom getters/setters:</div><div><br></div><div>private var foo:Int</div><div>private(file) var foo:Int</div><div>private(set: file) var foo:Int</div><div>private(get: global, set: file) var foo:Int</div><div><br></div><div><br></div><div>I guess, if we had some way to represent the standard getter/setter, that might work too. I don’t love it, but maybe with better wording?</div><div><br></div><div>var foo:Int{</div><div><span style="white-space:pre-wrap">        </span>public get useDefault</div><div><span style="white-space:pre-wrap">        </span>private(file) set {…}</div><div>}</div><div><br></div><div>Thanks,</div><div>Jon</div><div><div><div><div><br></div><div><br><div><blockquote type="cite"><div>On Mar 14, 2016, at 10:22 PM, Patrick Pijnappel <<a href="mailto:patrickpijnappel@gmail.com" target="_blank">patrickpijnappel@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div style="font-size:13px"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I like Shawn's proposal: </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="monospace, monospace">var foo: Int { private(file) set }</font> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="monospace, monospace"><br></font><font face="arial, helvetica, sans-serif">In fact it's probably more sensible than the current private(set) IMO.</font></blockquote></div><div style="font-size:13px"><font face="monospace, monospace"><br></font></div><div style="font-size:13px"><font face="arial, helvetica, sans-serif">For example, we already use</font></div><div style="font-size:13px"><span style="font-family:arial,helvetica,sans-serif"><br></span></div><div style="font-size:13px"><font face="monospace, monospace">var foo: Int { mutating get { ... } }<br></font></div><div style="font-size:13px"><span style="font-family:arial,helvetica,sans-serif"><br></span></div><div style="font-size:13px"><span style="font-family:arial,helvetica,sans-serif">and not</span><br></div><div style="font-size:13px"><span style="font-family:arial,helvetica,sans-serif"><br></span></div><div style="font-size:13px"><font face="monospace, monospace">mutating(get) var foo: Int { get { ... } }<br></font></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 15, 2016 at 4:13 PM, Patrick Pijnappel <span dir="ltr"><<a href="mailto:patrickpijnappel@gmail.com" target="_blank">patrickpijnappel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:13px">I like Shawn's proposal:</div><div style="font-size:13px"><br></div><div style="font-size:13px"><font face="monospace, monospace">var foo: Int { private(file) set }</font></div><div style="font-size:13px"><font face="monospace, monospace"><br></font></div><div style="font-size:13px"><font face="arial, helvetica, sans-serif">In fact it's probably more sensible than the current private(set) IMO.</font></div><div style="font-size:13px"><font face="monospace, monospace"><br></font></div><div style="font-size:13px"><br></div><div style="font-size:13px">While I like <font face="monospace, monospace">private(get: file, set: module)</font> idea, I think it just gets too inconsistent with <span style="font-family:monospace,monospace">private(set: public)</span><font face="arial, helvetica, sans-serif"> and</font><span style="font-family:monospace,monospace"> </span><span style="font-family:monospace,monospace">private(set: private)</span><font face="arial, helvetica, sans-serif"> (?!)</font></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Tue, Mar 15, 2016 at 3:39 PM, Jonathan Hull via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div style="word-wrap:break-word"><span><pre style="white-space:pre-wrap;background-color:rgb(255,255,255)"><i>On Mar 14, 2016, at 8:36 PM, Patrick Pijnappel via swift-evolution <<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">swift-evolution at swift.org</a>> wrote:</i></pre></span><blockquote type="cite"><pre style="white-space:pre-wrap;background-color:rgb(255,255,255)">The only question is (as Sean mentioned) how this combines with the syntax
for setter access level, e.g. the current private(set). Options:
- Unnamed 2nd argument, giving private(file), private(file, set),
private(set).
- Named 2nd argument, giving e.g. private(file), private(file, accessor:
set), private(accessor: set). Less ambiguity but longer.
- Not using multiple arguments, but that'd probably break consistency with
the other unification efforts going on to make everything look like
function calls.</pre></blockquote><div>What about the following 3 forms?</div><div><br></div><div>private(file) //both setter and getter have file scope</div><div>private(set: file) //setter has file scope. Equivalent to current “private(set)"</div><div>private(get: module, set: file) //getter has module scope & setter has file scope</div><div><br></div><div>It is a bit weird, but we should probably also allow “public" in that last form: private(get: public, set: module)</div><div><br></div><div>Thanks,</div><div>Jon</div></div><br></div></div><span>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></span></blockquote></div><br></div>
</blockquote></div><br></div></div>
</div></blockquote></div><br></div></div></div></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>