<div dir="ltr">Vladimir, I agree with Chris Lattner that function parameters are different from function return value in Swift.<div><br></div><div>Firstly, syntax of function call allows for easy forwarding of values, which came from different places, as parameters to a single function:</div><div>f(g(foo, 1), h(bar(buz)))</div><div><br></div><div>On the other hand, to play with multiple return values as freely, you need to perform pattern matching, which finishes current expression.</div><div><br></div><div>Secondly, there is no special sugar for tuples in return values, and function grammar does not need to know about it.</div><div><div><br></div><div>Thirdly, there are no special attributes for elements of tuple in function return type (second implies this).</div><div><br></div><div>Now, to <span style="color:rgb(0,0,0);white-space:pre-wrap">typealias f4 = () -> ((((((()))))))</span></div><div><font color="#000000"><span style="white-space:pre-wrap">I think it's OK, but we can remove Void and reduce the number of possible combinations.</span></font></div><div><font color="#000000"><span style="white-space:pre-wrap"><br></span></font></div><div><font color="#000000"><span style="white-space:pre-wrap">The fact that () and (()) are equal types is a general limitation of Swift type system: there are no single-element tuples.</span></font></div><div><font color="#000000"><span style="white-space:pre-wrap">But it is so for a reason: parentheses in expressions cannot be overloaded to construct single-element tuples.</span></font></div><div><br></div><div>- Anton</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-04-22 11:12 GMT+03:00 Антон Жилин <span dir="ltr"><<a href="mailto:antonyzhilin@gmail.com" target="_blank">antonyzhilin@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>+1, but this proposal need further work.</div><div>Specification of the new function grammar is needed.<br></div><div><br></div><div>Currently, it looks like:</div><div><br></div><div><span style="border:0px;font-size:14px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(128,128,128);font-style:italic;font-family:Helvetica,Arial,sans-serif;line-height:20.3px;background-image:initial;background-repeat:initial">function-type </span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial,sans-serif;font-size:14px;line-height:20.3px"></span><span style="border:0px;font-size:14px;margin:0px;outline:0px;padding:0px 0px 0px 4px;vertical-align:baseline;color:rgb(128,128,128);font-family:Helvetica,Arial,sans-serif;line-height:20.3px;background-image:initial;background-repeat:initial">→ </span><span style="border:0px;font-size:14px;margin:0px;outline:0px;padding:0px 4px;vertical-align:baseline;font-style:italic;color:rgb(0,0,0);font-family:Helvetica,Arial,sans-serif;line-height:20.3px;background-image:initial;background-repeat:initial"><a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Types.html#//apple_ref/swift/grammar/type" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,136,204);text-decoration:none;background:transparent" target="_blank">type</a></span><span style="border:0px;font-size:14px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,0,0);font-family:Helvetica,Arial,sans-serif;line-height:20.3px;background-image:initial;background-repeat:initial"><code style="border:0px;font-size:0.86em;margin:0px;outline:0px;padding:0px 4px;vertical-align:baseline;font-family:Menlo,monospace;font-weight:600;word-wrap:break-word;background:transparent">throws</code><sub style="border:0px;font-size:0.8em;margin-top:0px;margin-right:0px;margin-bottom:0px;outline:0px;padding:0px 4px 0px 0px;color:rgb(128,128,128);font-style:italic;background:transparent">opt</sub></span><code style="border:0px;font-size:0.86em;margin:0px;outline:0px;padding:0px 4px;vertical-align:baseline;color:rgb(0,0,0);font-family:Menlo,monospace;font-weight:600;word-wrap:break-word;line-height:20.3px;background-image:initial;background-repeat:initial">-></code><span style="border:0px;font-size:14px;margin:0px;outline:0px;padding:0px 4px;vertical-align:baseline;font-style:italic;color:rgb(0,0,0);font-family:Helvetica,Arial,sans-serif;line-height:20.3px;background-image:initial;background-repeat:initial"><a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Types.html#//apple_ref/swift/grammar/type" style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,136,204);text-decoration:none;background:transparent" target="_blank">type</a></span><br></div><div><br></div><div>It is already false, because some attributes can only be used in function types.</div><div><br></div><div>I suggest to rewrite it to something like:</div><div><p style="margin-bottom:0.0001pt;line-height:115%"><em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">function-type</span></em><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">→<span> </span></span><code style="border-radius:3px;background-color:rgba(0,0,0,0.0392157)"><span style="font-size:10pt;line-height:115%;font-family:Consolas;color:rgb(51,51,51)">(</span></code><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">function-parameter-types</span></em><sub><span style="font-size:9pt;line-height:115%;font-family:Helvetica,sans-serif;color:rgb(51,51,51)">opt</span></sub><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><code style="border-radius:3px;background-color:rgba(0,0,0,0.0392157)"><span style="font-size:10pt;line-height:115%;font-family:Consolas;color:rgb(51,51,51)">)</span></code><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><code style="border-radius:3px;background-color:rgba(0,0,0,0.0392157)"><span style="font-size:10pt;line-height:115%;font-family:Consolas;color:rgb(51,51,51)">-></span></code><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">type</span></em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"></span></p>
<p style="margin:0cm 0cm 0.0001pt;line-height:115%"><em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">function-type</span></em><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">→<span> </span></span><code style="border-radius:3px;background-color:rgba(0,0,0,0.0392157)"><span style="font-size:10pt;line-height:115%;font-family:Consolas;color:rgb(51,51,51)">(</span></code><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">function-parameter-types</span></em><sub><span style="font-size:9pt;line-height:115%;font-family:Helvetica,sans-serif;color:rgb(51,51,51)">opt</span></sub><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><code style="border-radius:3px;background-color:rgba(0,0,0,0.0392157)"><span style="font-size:10pt;line-height:115%;font-family:Consolas;color:rgb(51,51,51)">)</span></code><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><code style="border-radius:3px;background-color:rgba(0,0,0,0.0392157)"><span style="font-size:10pt;line-height:115%;font-family:Consolas;color:rgb(51,51,51)">throws</span></code><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><code style="border-radius:3px;background-color:rgba(0,0,0,0.0392157)"><span style="font-size:10pt;line-height:115%;font-family:Consolas;color:rgb(51,51,51)">-></span></code><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">type</span></em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"></span></p>
<p style="margin:0cm 0cm 0.0001pt;line-height:115%"><em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">function-type</span></em><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">→<span> </span></span><code style="border-radius:3px;background-color:rgba(0,0,0,0.0392157)"><span style="font-size:10pt;line-height:115%;font-family:Consolas;color:rgb(51,51,51)">(</span></code><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">function-parameter-types</span></em><sub><span style="font-size:9pt;line-height:115%;font-family:Helvetica,sans-serif;color:rgb(51,51,51)">opt</span></sub><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><code style="border-radius:3px;background-color:rgba(0,0,0,0.0392157)"><span style="font-size:10pt;line-height:115%;font-family:Consolas;color:rgb(51,51,51)">)</span></code><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><code style="border-radius:3px;background-color:rgba(0,0,0,0.0392157)"><span style="font-size:10pt;line-height:115%;font-family:Consolas;color:rgb(51,51,51)">rethrows</span></code><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><code style="border-radius:3px;background-color:rgba(0,0,0,0.0392157)"><span style="font-size:10pt;line-height:115%;font-family:Consolas;color:rgb(51,51,51)">-></span></code><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">type</span></em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"></span></p>
<p style="margin:0cm 0cm 0.0001pt;line-height:115%"><em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">function-parameter-types</span></em><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">→<span> </span><em>function-parameter-type</em></span></p><p style="margin:0cm 0cm 0.0001pt;line-height:115%"><em style="line-height:14.95px"><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">function-parameter-types</span></em><span style="line-height:14.95px"><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><span style="line-height:14.95px;font-family:Helvetica,sans-serif;color:rgb(51,51,51)">→<span> </span></span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"><em>function-parameter-type</em><span> </span></span><code style="border-radius:3px;background-color:rgba(0,0,0,0.0392157)"><span style="font-size:10pt;line-height:115%;font-family:Consolas;color:rgb(51,51,51)">,</span></code><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">function-parameter-types</span></em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"></span></p>
<p style="margin-top:0cm;line-height:115%"><em><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">function-parameter-type</span></em><span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)"> </span></span><span style="font-family:Helvetica,sans-serif;color:rgb(51,51,51)">→<span> </span><em>function-parameter-attributes</em><span> </span><em>type</em></span></p></div><div>It will also eliminate situation when you can pass () argument to a () → T function.</div><div>Function types Void->T will need to be migrated.</div><div><br></div><div>- Anton</div></div>
</blockquote></div><br></div>