-1<br><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 28, 2016 at 9:37 AM Tony Allevato via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">–1. I&#39;m not sure there&#39;s a reason to draw a line from removal-of-tuple-splat to removal-of-tuple-returns, other than the idea that they both involve tuples. In a lot of languages, purely-&quot;out&quot; parameters are a workaround for the fact that the language wasn&#39;t designed to allow functions to return multiple values easily. Since Swift does allow this, eliminating and adding &quot;out&quot; params is a step *backward*, not a step forward.<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">&quot;Inout&quot; parameters at least serve an important role with respect to in-place mutability. &quot;Out&quot;-only parameters don&#39;t seem like something that would have much value in Swift.<br class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The syntactic distinction between inputs and outputs in Swift&#39;s function syntax is important to readability—I find the example given with &quot;out&quot; params to be considerably harder to parse mentally than the version that returns a tuple. From the point of view of making the language easy for newcomers to learn... replacing tuple returns with &quot;out&quot; parameters would be extremely harmful.</div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Wed, Dec 28, 2016 at 3:10 AM Anton Zhilin via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="m_5854240714484172279m_7521060050161717650markdown-here-wrapper gmail_msg"><p style="margin:0px 0px 1.2em!important" class="gmail_msg">Some people on the list wondered, why we have moved from tuples in function parameters, but multiple returns are still implemented using tuples? The following code still compiles:</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="gmail_msg"><code class="m_5854240714484172279m_7521060050161717650hljs m_5854240714484172279m_7521060050161717650language-swift gmail_msg" 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);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span class="m_5854240714484172279m_7521060050161717650hljs-func gmail_msg"><span class="m_5854240714484172279m_7521060050161717650hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">func</span> <span class="m_5854240714484172279m_7521060050161717650hljs-title gmail_msg" style="color:rgb(153,0,0);font-weight:bold">position</span><span class="m_5854240714484172279m_7521060050161717650hljs-params gmail_msg">()</span> -&gt; <span class="m_5854240714484172279m_7521060050161717650hljs-params gmail_msg">(x: Int, y: Int)</span> </span>{
    <span class="m_5854240714484172279m_7521060050161717650hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">return</span> (x: <span class="m_5854240714484172279m_7521060050161717650hljs-number gmail_msg" style="color:rgb(0,128,128)">0</span>, y: <span class="m_5854240714484172279m_7521060050161717650hljs-number gmail_msg" style="color:rgb(0,128,128)">0</span>)
}

<span class="m_5854240714484172279m_7521060050161717650hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">let</span> (y, x) = position()
</code></pre>
<p style="margin:0px 0px 1.2em!important" class="gmail_msg">(Maybe it’s a bad example, because naturally we’d use <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);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="gmail_msg">Point</code> struct. Let’s pretend those two parameters don’t make sense as a struct.)</p>
<p style="margin:0px 0px 1.2em!important" class="gmail_msg">What I want to discuss is if we should introduce <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);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="gmail_msg">out</code> parameters <strong class="gmail_msg">and</strong> make them the default for multiple returns for Swift 4. The syntax would look like:</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="gmail_msg"><code class="m_5854240714484172279m_7521060050161717650hljs m_5854240714484172279m_7521060050161717650language-swift gmail_msg" 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);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span class="m_5854240714484172279m_7521060050161717650hljs-func gmail_msg"><span class="m_5854240714484172279m_7521060050161717650hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">func</span> <span class="m_5854240714484172279m_7521060050161717650hljs-title gmail_msg" style="color:rgb(153,0,0);font-weight:bold">position</span><span class="m_5854240714484172279m_7521060050161717650hljs-params gmail_msg">(x: out Int, y: out Int)</span> </span>{
    x = <span class="m_5854240714484172279m_7521060050161717650hljs-number gmail_msg" style="color:rgb(0,128,128)">0</span>
    y = <span class="m_5854240714484172279m_7521060050161717650hljs-number gmail_msg" style="color:rgb(0,128,128)">0</span>
}

<span class="m_5854240714484172279m_7521060050161717650hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">var</span> y
position(x: <span class="m_5854240714484172279m_7521060050161717650hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">let</span> x, y: y)
</code></pre>
<p style="margin:0px 0px 1.2em!important" class="gmail_msg"><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);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="gmail_msg">out</code> arguments can be any patterns allowed on the left side of assignment, including wildcard pattern and tuple destructuring pattern.</p>
<div title="MDH:PGRpdj5Tb21lIHBlb3BsZSBvbiB0aGUgbGlzdCB3b25kZXJlZCwgd2h5IHdlIGhhdmUgbW92ZWQg
ZnJvbSB0dXBsZXMgaW4gZnVuY3Rpb24gcGFyYW1ldGVycywgYnV0IG11bHRpcGxlIHJldHVybnMg
YXJlIHN0aWxsIGltcGxlbWVudGVkIHVzaW5nIHR1cGxlcz8gVGhlIGZvbGxvd2luZyBjb2RlIHN0
aWxsIGNvbXBpbGVzOjxicj48L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PmBgYHN3aWZ0PC9kaXY+
PGRpdj48ZGl2PmZ1bmMgcG9zaXRpb24oKSAtJmd0OyAoeDogSW50LCB5OiBJbnQpIHs8L2Rpdj48
ZGl2PiZuYnNwOyAmbmJzcDsgcmV0dXJuICh4OiAwLCB5OiAwKTwvZGl2PjxkaXY+fTwvZGl2Pjxk
aXY+PGJyPjwvZGl2PjxkaXY+bGV0ICh5LCB4KSA9IHBvc2l0aW9uKCk8L2Rpdj48L2Rpdj48ZGl2
PmBgYDwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+KE1heWJlIGl0J3MgYSBiYWQgZXhhbXBsZSwg
YmVjYXVzZSBuYXR1cmFsbHkgd2UnZCB1c2UgYFBvaW50YCBzdHJ1Y3QuIExldCdzIHByZXRlbmQg
dGhvc2UgdHdvIHBhcmFtZXRlcnMgZG9uJ3QgbWFrZSBzZW5zZSBhcyBhIHN0cnVjdC4pPC9kaXY+
PGRpdj48YnI+PC9kaXY+PGRpdj5XaGF0IEkgd2FudCB0byBkaXNjdXNzIGlzIGlmIHdlIHNob3Vs
ZCBpbnRyb2R1Y2UgYG91dGAgcGFyYW1ldGVycyAqKmFuZCoqIG1ha2UgdGhlbSB0aGUgZGVmYXVs
dCBmb3IgbXVsdGlwbGUgcmV0dXJucyBmb3IgU3dpZnQgNC4gVGhlIHN5bnRheCB3b3VsZCBsb29r
IGxpa2U6PC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5gYGBzd2lmdDwvZGl2PjxkaXY+ZnVuYyBw
b3NpdGlvbih4OiBvdXQgSW50LCB5OiBvdXQgSW50KSB7PC9kaXY+PGRpdj4mbmJzcDsgJm5ic3A7
IHggPSAwPC9kaXY+PGRpdj4mbmJzcDsgJm5ic3A7IHkgPSAwPC9kaXY+PGRpdj59PC9kaXY+PGRp
dj48YnI+PC9kaXY+PGRpdj52YXIgeTwvZGl2PjxkaXY+cG9zaXRpb24oeDogbGV0IHgsIHk6IHkp
PC9kaXY+PGRpdj5gYGA8L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PmBvdXRgIGFyZ3VtZW50cyBj
YW4gYmUgYW55IHBhdHRlcm5zIGFsbG93ZWQgb24gdGhlIGxlZnQgc2lkZSBvZiBhc3NpZ25tZW50
LCBpbmNsdWRpbmcgd2lsZGNhcmQgcGF0dGVybiBhbmQgdHVwbGUgZGVzdHJ1Y3R1cmluZyBwYXR0
ZXJuLjxicj48L2Rpdj4=" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0" class="gmail_msg">​</div></div></div>
_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div></div></div></div>
_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>