<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>I know you've already decided against this, but I think it deserves an explanation for why the two are different.<br></div>
<div><br></div>
<div>Tuples in function parameters was basically a special case to the type system. The function type was effectively modeled as taking one argument which was a tuple, and a function of multiple arguments just had a multi-element tuple. But this wasn't actually true. For one thing, you could have a single named argument, but you cannot have a 1-element tuple (named or no), which means the function argument isn't _really_ a tuple. For another, this caused weird behavior when invoking functions with a single tuple element. I don't remember the specifics anymore (I'm not sure I ever truly understood the rules around this), but in some cases you could pass a single tuple to a function expecting multiple arguments, but in other cases you couldn't.<br></div>
<div><br></div>
<div>So ultimately, getting rid of the notion that a function's arguments is a tuple was actually a simplification to the type system and to the internals, and made the rules a lot more straightforward.<br></div>
<div><br></div>
<div>Now contrast that with the return type. The return type is just a single value of *any* valid type. And a tuple is a valid type. Therefore, the return type can be a tuple. That's a straightforward consequence of the basic rules of the type system. Restricting it so functions couldn't return a tuple would be a complication to the type system, and a rather weird one at that. And that's without even considering the complexity and syntactical issues with your proposed `out` parameter.<br></div>
<div><br></div>
<div>-Kevin Ballard</div>
<div><br></div>
<div>On Wed, Dec 28, 2016, at 03:09 AM, Anton Zhilin via swift-evolution wrote:<br></div>
<blockquote type="cite"><div dir="ltr"><div style=""><p style="margin-top:0px !important;margin-right:0px !important;margin-bottom:1.2em !important;margin-left:0px !important;">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:<br></p><pre style="font-family:Consolas, Inconsolata, Courier, monospace;font-size:1em;line-height:1.2em;margin-top:1.2em;margin-right:0px;margin-bottom:1.2em;margin-left:0px;"><code style="font-size:0.85em;font-family:Consolas, Inconsolata, Courier, monospace;margin-top:0px;margin-right:0.15em;margin-bottom:0px;margin-left:0.15em;white-space:pre;overflow-y:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(204, 204, 204);border-right-color:rgb(204, 204, 204);border-bottom-color:rgb(204, 204, 204);border-left-color:rgb(204, 204, 204);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;overflow-x:auto;padding-top:0.5em;padding-right:0.5em;padding-bottom:0.5em;padding-left:0.5em;color:rgb(51, 51, 51);background-image:initial;background-attachment:initial;background-position-x:initial;background-position-y:initial;background-origin:initial;background-clip:initial;background-color:rgb(248, 248, 248);background-size:initial;display:block !important;"><span><span class="colour" style="color:rgb(51, 51, 51)"><b>func</b></span> <span class="colour" style="color:rgb(153, 0, 0)"><b>position</b></span><span>()</span> -&gt; <span>(x: Int, y: Int)</span> </span>{
    <span class="colour" style="color:rgb(51, 51, 51)"><b>return</b></span> (x: <span class="colour" style="color:rgb(0, 128, 128)">0</span>, y: <span class="colour" style="color:rgb(0, 128, 128)">0</span>)
}

<span class="colour" style="color:rgb(51, 51, 51)"><b>let</b></span> (y, x) = position()
</code><br></pre><p style="margin-top:0px !important;margin-right:0px !important;margin-bottom:1.2em !important;margin-left:0px !important;">(Maybe it’s a bad example, because naturally we’d use <code style="font-size:0.85em;font-family:Consolas, Inconsolata, Courier, monospace;margin-top:0px;margin-right:0.15em;margin-bottom:0px;margin-left:0.15em;padding-top:0px;padding-right:0.3em;padding-bottom:0px;padding-left:0.3em;white-space:pre-wrap;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(234, 234, 234);border-right-color:rgb(234, 234, 234);border-bottom-color:rgb(234, 234, 234);border-left-color:rgb(234, 234, 234);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:rgb(248, 248, 248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;">Point</code> struct. Let’s pretend those two parameters don’t make sense as a struct.)<br></p><p style="margin-top:0px !important;margin-right:0px !important;margin-bottom:1.2em !important;margin-left:0px !important;">What I want to discuss is if we should introduce <code style="font-size:0.85em;font-family:Consolas, Inconsolata, Courier, monospace;margin-top:0px;margin-right:0.15em;margin-bottom:0px;margin-left:0.15em;padding-top:0px;padding-right:0.3em;padding-bottom:0px;padding-left:0.3em;white-space:pre-wrap;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(234, 234, 234);border-right-color:rgb(234, 234, 234);border-bottom-color:rgb(234, 234, 234);border-left-color:rgb(234, 234, 234);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:rgb(248, 248, 248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;">out</code> parameters <b>and</b> make them the default for multiple returns for Swift 4. The syntax would look like:<br></p><pre style="font-family:Consolas, Inconsolata, Courier, monospace;font-size:1em;line-height:1.2em;margin-top:1.2em;margin-right:0px;margin-bottom:1.2em;margin-left:0px;"><code style="font-size:0.85em;font-family:Consolas, Inconsolata, Courier, monospace;margin-top:0px;margin-right:0.15em;margin-bottom:0px;margin-left:0.15em;white-space:pre;overflow-y:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(204, 204, 204);border-right-color:rgb(204, 204, 204);border-bottom-color:rgb(204, 204, 204);border-left-color:rgb(204, 204, 204);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;overflow-x:auto;padding-top:0.5em;padding-right:0.5em;padding-bottom:0.5em;padding-left:0.5em;color:rgb(51, 51, 51);background-image:initial;background-attachment:initial;background-position-x:initial;background-position-y:initial;background-origin:initial;background-clip:initial;background-color:rgb(248, 248, 248);background-size:initial;display:block !important;"><span><span class="colour" style="color:rgb(51, 51, 51)"><b>func</b></span> <span class="colour" style="color:rgb(153, 0, 0)"><b>position</b></span><span>(x: out Int, y: out Int)</span> </span>{
    x = <span class="colour" style="color:rgb(0, 128, 128)">0</span>
    y = <span class="colour" style="color:rgb(0, 128, 128)">0</span>
}

<span class="colour" style="color:rgb(51, 51, 51)"><b>var</b></span> y
position(x: <span class="colour" style="color:rgb(51, 51, 51)"><b>let</b></span> x, y: y)
</code><br></pre><p style="margin-top:0px !important;margin-right:0px !important;margin-bottom:1.2em !important;margin-left:0px !important;"><code style="font-size:0.85em;font-family:Consolas, Inconsolata, Courier, monospace;margin-top:0px;margin-right:0.15em;margin-bottom:0px;margin-left:0.15em;padding-top:0px;padding-right:0.3em;padding-bottom:0px;padding-left:0.3em;white-space:pre-wrap;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(234, 234, 234);border-right-color:rgb(234, 234, 234);border-bottom-color:rgb(234, 234, 234);border-left-color:rgb(234, 234, 234);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:rgb(248, 248, 248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;">out</code> arguments can be any patterns allowed on the left side of assignment, including wildcard pattern and tuple destructuring pattern.<br></p><div title="MDH:PGRpdj5Tb21lIHBlb3BsZSBvbiB0aGUgbGlzdCB3b25kZXJlZCwgd2h5IHdlIGhhdmUgbW92ZWQg&#x0a;ZnJvbSB0dXBsZXMgaW4gZnVuY3Rpb24gcGFyYW1ldGVycywgYnV0IG11bHRpcGxlIHJldHVybnMg&#x0a;YXJlIHN0aWxsIGltcGxlbWVudGVkIHVzaW5nIHR1cGxlcz8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Rpdj4mbmJzcDsgJm5ic3A7IHkgPSAwPC9kaXY+PGRpdj59PC9kaXY+PGRp&#x0a;dj48YnI+PC9kaXY+PGRpdj52YXIgeTwvZGl2PjxkaXY+cG9zaXRpb24oeDogbGV0IHgsIHk6IHkp&#x0a;PC9kaXY+PGRpdj5gYGA8L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PmBvdXRgIGFyZ3VtZW50cyBj&#x0a;YW4gYmUgYW55IHBhdHRlcm5zIGFsbG93ZWQgb24gdGhlIGxlZnQgc2lkZSBvZiBhc3NpZ25tZW50&#x0a;LCBpbmNsdWRpbmcgd2lsZGNhcmQgcGF0dGVybiBhbmQgdHVwbGUgZGVzdHJ1Y3R1cmluZyBwYXR0&#x0a;ZXJuLjxicj48L2Rpdj4=" style="height:0px;width:0px;max-height:0px;max-width:0px;overflow-y:hidden;overflow-x:hidden;font-size:0em;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;"><br></div>
</div>
</div>
<div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</blockquote><div><br></div>
</body>
</html>