<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On 12 Jul 2016, at 00:20, Jacob Bandes-Storch <<a href="mailto:jtbandes@gmail.com" class="">jtbandes@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">When would you want to use this instead of something like `button[imageFor: .normal]` ?</div></div></blockquote><div><br class=""></div><div>All the time, basically. Primarily because IMO it doesn’t really make sense to make “image” part of the argument label for the control state - we just have to (using subscripts) because subscripts themselves can’t be named. I think most people would agree that</div><div><br class=""></div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> image = </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">button</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">image</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">for</span><span style="font-variant-ligatures: no-common-ligatures" class="">: .</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">normal</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div></div><div><br class=""></div><div>is more readable than</div><div><br class=""></div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> image = </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">button</span><span style="font-variant-ligatures: no-common-ligatures" class="">[imageFor: .normal]</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">and likewise, I would prefer</span></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">button</span>.image(<span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">for</span>: .normal) = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">image</span></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">over</span></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">button</span>[imageFor: .normal] = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">image</span></span></div></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra">
<div class="gmail_quote">On Mon, Jul 11, 2016 at 3:00 PM, Tim Vermeulen 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=""><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="">Slightly related to this, I would really love to have non-subscript parameterized properties. It would allow us to write<div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:#4f8187" class="">button</span><span class="">.image(</span><span style="color:#ba2da2" class="">for</span><span class="">: .normal) = </span><span style="color:#4f8187" class="">image</span></div></div><div class=""><br class=""></div><div class="">instead of</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span class="">button</span><span style="" class="">.</span><span style="color:#3e1e81" class="">setImage</span><span style="" class="">(</span><span class="">image</span><span style="" class="">, </span><span style="color:#ba2da2" class="">for</span><span style="" class="">: .</span><span style="color:#703daa" class="">normal</span><span style="" class="">)</span></div></div><div class=""><br class=""></div><div class="">The same can be achieved through subscripts, but it’s not always as nice. It would bring subscripts and computed properties closer together, which also seems to be the goal of your proposal. Perhaps the two ideas could be combined?<span class=""><br class=""><div class=""><br class=""></div><div class="">> Subscripts are a hybrid of properties and functions, since they have a parameter list, as well as getters and setters, so use of either symbol will be unusual in this case.<br class="">> <br class="">> However, I think a colon is more suitable, since it implies the possibility to set the value.<br class="">> <br class="">> <br class="">> In the future, if we add throwing getters/ setters:<br class="">> <br class="">> subscript(_ position: Int) ->Element {<br class="">> get {<br class="">> return …<br class="">> }<br class="">> throwing set {<br class="">> …<br class="">> }<br class="">> }<br class="">> <br class="">> Should this require ‘throws ->Element’? Using a colon also removes this potentially confusing case.<br class="">> <br class="">> <br class="">> Thoughts?<br class="">> <br class="">> <br class="">><span class=""> </span>
</div></span></div></div><br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" 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=""></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>