<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="">What about this?</div><div class=""><br class=""></div>let l = someViewController.view.layer<div class="">l.shadowColor = UIColor.grayColor().CGColor</div><div class="">l.shadowRadius = 5.0</div><div class="">l.shadowOffset = CGSizeMake(0.0, 0.5)</div><div class="">l.shadowOpacity = 0.75</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 15 Dec 2015, at 22:48, Chuquimia, Max via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div dir="ltr" class=""><div class="markdown-here-wrapper" style=""><p style="margin:1.2em 0px!important" class="">Greetings, fellow Swiftlets!</p><p style="margin:1.2em 0px!important" class="">I am very interested to hear what you guys think about method chaining in a similar style to Swift’s bitmask handling.<br class="">Yes, there’s a healthy discussion on “Setup Closures”, but let’s <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">dispatch_async</code> to start a new (albeit parallel) thread regarding a neat way to access properties.<br class="">No doubt you’ve found yourself writing something similar to the following:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class=""><code class="language-swift hljs" style="font-size: 0.85em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 0px 0.15em; white-space: pre; overflow: auto; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: 1px solid rgb(204, 204, 204); padding: 0.5em; background-color: rgb(255, 255, 255); display: block !important; background-position: initial initial; background-repeat: initial initial;">someViewController.view.layer.shadowColor = <span class="hljs-type" style="color:rgb(92,38,153)">UIColor</span>.grayColor().<span class="hljs-type" style="color:rgb(92,38,153)">CGColor</span>
someViewController.view.layer.shadowRadius = <span class="hljs-number" style="color:rgb(28,0,207)">5.0</span>
someViewController.view.layer.shadowOffset = <span class="hljs-type" style="color:rgb(92,38,153)">CGSizeMake</span>(<span class="hljs-number" style="color:rgb(28,0,207)">0.0</span>, <span class="hljs-number" style="color:rgb(28,0,207)">0.5</span>)
someViewController.view.layer.shadowOpacity = <span class="hljs-number" style="color:rgb(28,0,207)">0.75</span>
</code></pre><p style="margin:1.2em 0px!important" class="">It can be disturbing to see <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">someViewController.view.layer</code> repeated so many times, however we are currently unable to refactor these lines without subclassing and possibly affecting other areas of implementation.</p><p style="margin:1.2em 0px!important" class="">What I propose is a natural way of assigning properties on <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">layer</code> with a syntax we are all already used to:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class=""><code class="language-swift hljs" style="font-size: 0.85em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 0px 0.15em; white-space: pre; overflow: auto; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: 1px solid rgb(204, 204, 204); padding: 0.5em; background-color: rgb(255, 255, 255); display: block !important; background-position: initial initial; background-repeat: initial initial;">someViewController.view.layer = [
.shadowColor = <span class="hljs-type" style="color:rgb(92,38,153)">UIColor</span>.grayColor().<span class="hljs-type" style="color:rgb(92,38,153)">CGColor</span>,
.shadowRadius = <span class="hljs-number" style="color:rgb(28,0,207)">5.0</span>,
.shadowOffset = <span class="hljs-type" style="color:rgb(92,38,153)">CGSizeMake</span>(<span class="hljs-number" style="color:rgb(28,0,207)">0.0</span>, <span class="hljs-number" style="color:rgb(28,0,207)">0.5</span>),
.shadowOpacity = <span class="hljs-number" style="color:rgb(28,0,207)">0.75</span>
]
</code></pre><p style="margin:1.2em 0px!important" class="">Which is of course similar to our belovèd <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">someViewController.view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]</code></p><p style="margin:1.2em 0px!important" class="">Of course, this is an extreme example of keypath length, however I believe this language feature would still be beneficial for shorter keypaths (think accessing <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">self</code> within closures or the recent proposal to reinstate <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">self.</code>)</p><p style="margin:1.2em 0px!important" class="">Using <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">[]</code> instead of <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">{}</code> eliminates the risk of ambiguity if a method such as <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">func layer(c: Void -> Void)</code> has been defined in the <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">view</code>’s class. Apart from that, I can’t think of any possible conflicts, and as it’s an addition there will be no migration required when moving to a new language version</p><p style="margin:1.2em 0px!important" class="">Interested in your thoughts,</p><p style="margin:1.2em 0px!important" class="">MaxC</p>
<div title="MDH:CgoKCgoKCgo8cCBjbGFzcz0iIj5HcmVldGluZ3MsIGZlbGxvdyBTd2lmdGxldHMhPC9wPgo8cCBj
bGFzcz0iIj5JIGFtIHZlcnkgaW50ZXJlc3RlZCB0byBoZWFyIHdoYXQgeW91IGd1eXMgdGhpbmsg
YWJvdXQgbWV0aG9kIGNoYWluaW5nIGluIGEgc2ltaWxhciBzdHlsZSB0byBTd2lmdOKAmXMgYml0
bWFzayBoYW5kbGluZy48L3A+PHAgY2xhc3M9IiI+WWVzLCB0aGVyZeKAmXMgYSBoZWFsdGh5IGRp
c2N1c3Npb24gb24g4oCcU2V0dXAgQ2xvc3VyZXPigJ0sIGJ1dCBsZXTigJlzIGBkaXNwYXRjaF9h
c3luY2AgdG8gc3RhcnQgYSBuZXcgKGFsYmVpdCBwYXJhbGxlbCkgdGhyZWFkIHJlZ2FyZGluZyBh
IG5lYXQgd2F5IHRvIGFjY2VzcyBwcm9wZXJ0aWVzLjwvcD48cCBjbGFzcz0iIj5ObyBkb3VidCB5
b3XigJl2ZSBmb3VuZCB5b3Vyc2VsZiB3cml0aW5nIHNvbWV0aGluZyBzaW1pbGFyIHRvIHRoZSBm
b2xsb3dpbmc6PC9wPgo8cCBjbGFzcz0iIj5gYGBzd2lmdDxicj5zb21lVmlld0NvbnRyb2xsZXIu
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8gbWlncmF0aW9uIHJlcXVpcmVkIHdoZW4gbW92aW5nIHRvIGEgbmV3
IGxhbmd1YWdlIHZlcnNpb248L3A+PHAgY2xhc3M9IiI+PGJyPjwvcD4KPHAgY2xhc3M9IiI+SW50
ZXJlc3RlZCBpbiB5b3VyIHRob3VnaHRzLDwvcD4KPHAgY2xhc3M9IiI+TWF4QzwvcD4=" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0" class=""></div></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=tTTJ5sn5y0uc3ODSZa-2BndLNwXCDS7T2cq5OlDDhG0Ruosa42rte9eIUTeiD80JvzjO-2B0n-2BtvwPcSSCjWM-2F8a5VLeAMQ0sRGXftBIqtb19QzMKfX3myYv5kMEJNUQ6A5Wb4DI-2BQT0YhhvNnlrCL1fNZxqUrbMTHduyoTdwx-2Fow4-2BfZ7IMXGRYW-2F4KMXE6wW2YeftbZZH5dos-2FF5YwfCzxYMOcbtOH8gD-2B0ltIkJ1Bco0-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>