<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="">I like this because it removes another C-like artifact that can be misunderstood ("&amp; creates a pointer to this object") but I defer to Joe to make the call.</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Jan 29, 2016, at 12:47 PM, Trent Nadeau &lt;<a href="mailto:tanadeau@gmail.com" class="">tanadeau@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">+1<div class=""><br class=""></div><div class="">I would also like to change the call site to use <font face="monospace, monospace" class="">inout</font> as well.</div><div class=""><br class=""></div><div class=""><font face="monospace, monospace" class="">foo(inout myVariable)</font></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Jan 29, 2016 at 2:40 PM, Dave via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</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="">+1<br class=""><div class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="">On Jan 29, 2016, at 11:37, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""></div></div><div class=""><div class=""><div class=""><div style="word-wrap:break-word" class=""><a href="https://github.com/apple/swift-evolution/pull/127" target="_blank" class="">https://github.com/apple/swift-evolution/pull/127</a><div class=""><br class=""></div><div class=""><h1 style="margin:0px 0px 0.875em;font-size:1.5em;line-height:0.875em;font-family:'Helvetica Neue',Helvetica,Arial,Verdana,sans-serif" class="">Adjusting&nbsp;<code class="">inout</code>&nbsp;Declarations for Type Decoration</h1><ul style="color:rgb(17,17,17);font-family:'Helvetica Neue',Helvetica,Arial,Verdana,sans-serif;font-size:16px" class=""><li style="font-size:18px" class="">Proposal: TBD</li><li style="font-size:18px" class="">Author(s):&nbsp;<a href="https://github.com/jckarter" style="color:rgb(13,110,161);text-decoration:none" target="_blank" class="">Joe Groff</a>,&nbsp;<a href="http://github.com/erica" style="color:rgb(13,110,161);text-decoration:none" target="_blank" class="">Erica Sadun</a></li><li style="font-size:18px" class="">Status: TBD</li><li style="font-size:18px" class="">Review manager: TBD</li></ul><h2 style="color:rgb(17,17,17);margin:0px 0px 0.9545454545454546em;font-size:1.375em;line-height:0.9545454545454546em;font-family:'Helvetica Neue',Helvetica,Arial,Verdana,sans-serif" class="">Introduction</h2><p style="color:rgb(17,17,17);font-family:'Helvetica Neue',Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;font-size:1.1429em;line-height:1.3125em;margin:1.3125em 0px" class="">The&nbsp;<code class="">inout</code>&nbsp;keyword indicates copy-in/copy-out argument behavior. In its current implementation<br class="">the keyword prepands argument names. We propose to move the&nbsp;<code class="">inout</code>&nbsp;keyword to the right<br class="">side of the colon to decorate the type instead of the parameter label.&nbsp;</p><p style="color:rgb(17,17,17);font-family:'Helvetica Neue',Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;font-size:1.1429em;line-height:1.3125em;margin:1.3125em 0px" class=""><em class="">The initial Swift-Evolution discussion of this topic took place in the “Replace ‘inout’ with &amp;” thread.</em></p><h2 style="color:rgb(17,17,17);margin:0px 0px 0.9545454545454546em;font-size:1.375em;line-height:0.9545454545454546em;font-family:'Helvetica Neue',Helvetica,Arial,Verdana,sans-serif" class="">Motivation</h2><p style="color:rgb(17,17,17);font-family:'Helvetica Neue',Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;font-size:1.1429em;line-height:1.3125em;margin:1.3125em 0px" class="">In Swift 2, the&nbsp;<code class="">inout</code>&nbsp;parameter lives on the label side rather than the type side of the colon<br class="">although the keyword isn’t modifying the label but its type. Decorating<br class="">types instead of labels offers identifiable advantages:&nbsp;</p><ul style="color:rgb(17,17,17);font-family:'Helvetica Neue',Helvetica,Arial,Verdana,sans-serif;font-size:16px" class=""><li style="font-size:18px" class=""><div style="word-wrap:break-word;line-height:1.3125em;margin:0px" class="">It enables the&nbsp;<code class="">inout</code>&nbsp;keyword to properly integrate into full type syntax, for example:&nbsp;</div><pre class=""><code style="display:block;padding:0.5em;color:rgb(51,51,51);background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial" class=""><span class=""><span style="color:rgb(153,0,0);font-weight:bold" class="">(x: inout T)</span> -&gt;</span> U <span style="color:rgb(0,153,38)" class="">//</span><span class=""> =&gt;</span> <span class=""><span style="color:rgb(153,0,0);font-weight:bold" class="">(inout T)</span> -&gt;</span> U</code></pre></li><li style="font-size:18px" class=""><div style="word-wrap:break-word;line-height:1.3125em;margin:0px" class="">It avoids notational similarity with arguments labeled&nbsp;<code class="">inout</code>, for example:</div><pre class=""><code style="display:block;padding:0.5em;color:rgb(51,51,51);background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial" class="">func foo<span class=""><span style="color:rgb(153,0,0);font-weight:bold" class="">(inOut x: T)</span> // <span style="color:rgb(153,0,0);font-weight:bold" class="">foo</span><span style="color:rgb(153,0,0);font-weight:bold" class="">(inOut:)</span>, <span style="color:rgb(153,0,0);font-weight:bold" class="">type</span> <span style="color:rgb(153,0,0);font-weight:bold" class="">(T)</span> -&gt;</span> Void
func foo<span class=""><span style="color:rgb(153,0,0);font-weight:bold" class="">(inout x: T)</span> // <span style="color:rgb(153,0,0);font-weight:bold" class="">foo</span><span style="color:rgb(153,0,0);font-weight:bold" class="">(_:)</span>, <span style="color:rgb(153,0,0);font-weight:bold" class="">type</span> <span style="color:rgb(153,0,0);font-weight:bold" class="">(inout T)</span> -&gt;</span> Void</code></pre></li><li style="font-size:18px" class=""><div style="word-wrap:break-word;line-height:1.3125em;margin:0px" class="">It better matches similar patterns in other languages such as borrowing in Rust, that may be later introduced back to Swift&nbsp;</div></li></ul><h2 style="color:rgb(17,17,17);margin:0px 0px 0.9545454545454546em;font-size:1.375em;line-height:0.9545454545454546em;font-family:'Helvetica Neue',Helvetica,Arial,Verdana,sans-serif" class="">Detailed design</h2><pre style="color:rgb(17,17,17);font-size:16px" class=""><code style="display:block;padding:0.5em;color:rgb(51,51,51);background-color:rgb(248,248,248);background-position:initial initial;background-repeat:initial initial" class="">parameter → external<span style="color:rgb(0,128,128)" class="">-parameter</span><span style="color:rgb(0,128,128)" class="">-name</span> optlocal<span style="color:rgb(0,128,128)" class="">-parameter</span><span style="color:rgb(0,128,128)" class="">-name</span> : <span style="font-weight:bold" class="">type</span><span style="color:rgb(0,128,128)" class="">-annotation</span>
<span style="font-weight:bold" class="">type</span><span style="color:rgb(0,128,128)" class="">-annotation</span> → inout <span style="font-weight:bold" class="">type</span><span style="color:rgb(0,128,128)" class="">-annotation</span></code></pre><h2 style="color:rgb(17,17,17);margin:0px 0px 0.9545454545454546em;font-size:1.375em;line-height:0.9545454545454546em;font-family:'Helvetica Neue',Helvetica,Arial,Verdana,sans-serif" class="">Alternatives Considered</h2><p style="color:rgb(17,17,17);font-family:'Helvetica Neue',Helvetica,Arial,Verdana,sans-serif;word-wrap:break-word;font-size:1.1429em;line-height:1.3125em;margin:1.3125em 0px" class="">Decorations using&nbsp;<code class="">@inout</code>&nbsp;(either&nbsp;<code class="">@inout(T)</code>&nbsp;or&nbsp;<code class="">@inout T</code>) were considered and discarded</p></div></div></div></div>_______________________________________________<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" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div><br 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=""></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="">Trent Nadeau</div>
</div></div>
</div></blockquote></div><br class=""></body></html>