<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=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class=""><pre style="white-space: pre-wrap;" class="">On Tue, Mar 15, 2016 at 2:33 PM Erica Sadun <<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">erica at ericasadun.com</a>> wrote:</pre><div class=""><blockquote type="cite" class=""><pre style="white-space: pre-wrap;" class="">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>I like Shawn’s proposal better for cases where there are custom getter/setter implementations. We should definitely be able to do:<div class=""><br class=""></div><div class="">var foo:Int {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>public get {…}</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>private(file) set {…}</div><div class="">}</div><div class=""><br class=""></div><div class="">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 class="">before</i> the custom getter/setter).</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">private var foo:Int</div><div class="">private(file) var foo:Int</div><div class="">private(set: file) var foo:Int</div><div class="">private(get: global, set: file) var foo:Int</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">var foo:Int{</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>public get useDefault</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>private(file) set {…}</div><div class="">}</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Jon</div><div class=""><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 14, 2016, at 10:22 PM, Patrick Pijnappel <<a href="mailto:patrickpijnappel@gmail.com" class="">patrickpijnappel@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div style="font-size:13px" class=""><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" class="">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" class=""><br class=""></font><font face="arial, helvetica, sans-serif" class="">In fact it's probably more sensible than the current private(set) IMO.</font></blockquote></div><div style="font-size:13px" class=""><font face="monospace, monospace" class=""><br class=""></font></div><div style="font-size:13px" class=""><font face="arial, helvetica, sans-serif" class="">For example, we already use</font></div><div style="font-size:13px" class=""><span style="font-family:arial,helvetica,sans-serif" class=""><br class=""></span></div><div style="font-size:13px" class=""><font face="monospace, monospace" class="">var foo: Int { mutating get { ... } }<br class=""></font></div><div style="font-size:13px" class=""><span style="font-family:arial,helvetica,sans-serif" class=""><br class=""></span></div><div style="font-size:13px" class=""><span style="font-family:arial,helvetica,sans-serif" class="">and not</span><br class=""></div><div style="font-size:13px" class=""><span style="font-family:arial,helvetica,sans-serif" class=""><br class=""></span></div><div style="font-size:13px" class=""><font face="monospace, monospace" class="">mutating(get) var foo: Int { get { ... } }<br class=""></font></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Mar 15, 2016 at 4:13 PM, Patrick Pijnappel <span dir="ltr" class=""><<a href="mailto:patrickpijnappel@gmail.com" target="_blank" class="">patrickpijnappel@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div style="font-size:13px" class="">I like Shawn's proposal:</div><div style="font-size:13px" class=""><br class=""></div><div style="font-size:13px" class=""><font face="monospace, monospace" class="">var foo: Int { private(file) set }</font></div><div style="font-size:13px" class=""><font face="monospace, monospace" class=""><br class=""></font></div><div style="font-size:13px" class=""><font face="arial, helvetica, sans-serif" class="">In fact it's probably more sensible than the current private(set) IMO.</font></div><div style="font-size:13px" class=""><font face="monospace, monospace" class=""><br class=""></font></div><div style="font-size:13px" class=""><br class=""></div><div style="font-size:13px" class="">While I like <font face="monospace, monospace" class="">private(get: file, set: module)</font> idea, I think it just gets too inconsistent with <span style="font-family:monospace,monospace" class="">private(set: public)</span><font face="arial, helvetica, sans-serif" class=""> and</font><span style="font-family:monospace,monospace" class=""> </span><span style="font-family:monospace,monospace" class="">private(set: private)</span><font face="arial, helvetica, sans-serif" class=""> (?!)</font></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote"><div class=""><div class="">On Tue, Mar 15, 2016 at 3:39 PM, Jonathan Hull via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><div class=""><div style="word-wrap:break-word" class=""><span class=""><pre style="white-space:pre-wrap;background-color:rgb(255,255,255)" class=""><i class="">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" class="">swift-evolution at swift.org</a>> wrote:</i></pre></span><blockquote type="cite" class=""><pre style="white-space:pre-wrap;background-color:rgb(255,255,255)" class="">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 class="">What about the following 3 forms?</div><div class=""><br class=""></div><div class="">private(file) //both setter and getter have file scope</div><div class="">private(set: file) //setter has file scope. Equivalent to current “private(set)"</div><div class="">private(get: module, set: file) //getter has module scope & setter has file scope</div><div class=""><br class=""></div><div class="">It is a bit weird, but we should probably also allow “public" in that last form: private(get: public, set: module)</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Jon</div></div><br class=""></div></div><span class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></span></blockquote></div><br class=""></div>
</blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></div></div></body></html>