<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 have a different read of the proposal I guess... I actually find that this:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">(Int, Int) -> (Int, Int)</font></div></blockquote><div class=""><br class=""></div><div class="">Naturally reads take a single pair (e.g. tuple) of (Int, Int) and return a single pair of (Int, Int)</div><div class=""><br class=""></div><div class="">This actually looks and feels like the right implementation to me:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">let tx: (Int, Int) -> (Int, Int) = { ($0.1, $0.0) }</font></div></blockquote><div class=""><br class=""></div><div class=""><div class="">And I am saying that this would be explicitly wrong:</div><div class=""><br class=""></div><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class=""><font face="Menlo" class="">let tx: (Int, Int) -> (Int, Int) = { ($1, $0) }</font></blockquote></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class="">If I wanted a type signature of that took two Int params, I would expect to write this:</div><div class=""><br class=""></div><div class=""><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class=""><font face="Menlo" class="">let tx: Int, Int -> (Int, Int) = { ($1, $0) }</font></blockquote></div><div class=""><br class=""></div><div class="">That reads, a type signature that takes two Int values and returns a single (Int, Int) pair.</div><div class=""><br class=""></div><div class="">The problem, to me at least, is that the function declaration overloads the meaning of () as "start of parameter list for function declaration".</div><div class=""><br class=""></div><div class=""><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class=""><font face="Menlo" class="">func tx((Int, Int)) -> (Int, Int) { return ($0.1, $0.0) }</font></blockquote></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class="">So now you have this mess to say the same thing: take a single pair of Int and return a pair of Int.</div><div class=""><br class=""></div><div class="">Similarly, if the () are going to required for parameter lists in function declarations, I really struggle to see why these two forms should mean the same thing:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">y = x.sorted { (lhs, rhs) in rhs < lhs }</font></div><div class=""><font face="Menlo" class="">y = x.sorted { lhs, rhs in rhs < lhs }</font></div></blockquote><div class=""><br class=""></div><div class="">Dropping the type signatures because that can be inferred is one thing, but changing the structure of the parameter list seems like an orthogonal optimization.</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">y = x.sorted { (lhs : Int, rhs : Int) -> Bool in rhs < lhs }</font></div><div class=""><font face="Menlo" class="">y = x.sorted { (lhs, rhs) in rhs < lhs }</font></div><div class=""><font face="Menlo" class="">{ $1 < $0 }</font></div></blockquote><div class=""><br class=""></div><div class="">This process keeps the structural elements while dropping all of the type pieces and maintains the consistency that in function types (regardless of how they are defined), the () denotes a parameter list. If you actually want a tuple within the parameter list, you need to do `((lhs, rhs))`.</div><div class=""><br class=""></div><div class="">-David</div><div class=""><br class=""></div><div class=""><div class=""><div><blockquote type="cite" class=""><div class="">On Apr 19, 2016, at 9:24 AM, Erica Sadun 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 style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 19, 2016, at 9:44 AM, David Rönnqvist <<a href="mailto:david.ronnqvist@gmail.com" class="">david.ronnqvist@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Would this also affect the syntax for naming closure arguments? For example, would this (taken from "The Swift Programming Language (Swift 2.2)”):</div><div class=""><ol class="code-lines" style="border: 0px; font-size: 14px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; counter-reset: li 0; line-height: 1.6em; list-style: none; font-family: Helvetica, Arial, sans-serif;"><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -13px; white-space: pre-wrap; color: rgb(255, 255, 255); content: ' '; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);"> reversed</span> = <span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">names</span>.<span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">sort</span>( { <span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">s1</span>, <span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">s2</span> <span class="kt" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145);">in</span> <span class="kt" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145);">return</span> <span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">s1</span> > <span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">s2</span> } )</code></li></ol></div><div class="">have to be written like this:</div><div class=""><ol class="code-lines" style="border: 0px; font-size: 14px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; counter-reset: li 0; line-height: 1.6em; list-style: none; font-family: Helvetica, Arial, sans-serif;"><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -13px; white-space: pre-wrap; color: rgb(255, 255, 255); content: ' '; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);"> reversed</span> = <span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">names</span>.<span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">sort</span>( { (<span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">s1</span>, <span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">s2</span>) <span class="kt" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145);">in</span> <span class="kt" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145);">return</span> <span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">s1</span> > <span class="vc" style="border: 0px; font-size: 11.899999618530273px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">s2</span> } )</code></li></ol></div><div class="">or is that a different syntax?</div><div class=""><br class=""></div><div class="">As a developer focused on _writing_ and _reading_ code like this, I don’t see the real benefits of this change. It only feels natural to me that I would be able to omit the parentheses when there is only one type, but that I would need them to group multiple arguments or to label arguments.</div><div class=""><br class=""></div><div class="">That said, I don’t feel strongly about it and the work of transitioning our code would be minimal. If this change provides other engineering benefits that aren’t noticeable on the surface, then I’m positive to the change for those reasons.</div><div class=""><br class=""></div><div class="">- David</div></div></div></blockquote></div><br class=""><div class="">It would not affect the closure syntax. To paraphrase Chris:</div><div class=""><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="">No. Swift’s syntactic shortcuts in its <span class="searchResult" style="background-color: rgba(255, 252, 141, 0.701961); border-top-left-radius: 6px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; color: rgb(34, 34, 34) !important; background-position: initial initial; background-repeat: initial initial;">closure</span> parameter lists benefit simple functional algorithms. Few people would choose to write fully specified long-form declarations when, for example, reverse-sorting an array of integers:</p><pre style="color: rgb(17, 17, 17); font-size: 16px;" class=""><code class="swift coffeescript hljs" 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;">y = x.sorted { <span class="hljs-function"><span class="hljs-params" style="color: rgb(153, 0, 0); font-weight: bold;">(lhs : Int, rhs : Int)</span> -></span> Bool <span class="hljs-keyword" style="font-weight: bold;">in</span> rhs < lhs }</code></pre><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="">Compare the long form with this simpler form:</p><pre style="color: rgb(17, 17, 17); font-size: 16px;" class=""><code class="swift actionscript hljs" 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;">y = x.sorted { lhs, rhs <span class="hljs-keyword" style="font-weight: bold;">in</span> rhs < lhs }</code></pre><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="">You can use the even shorter form of <code class="">{ $1 < $0 }</code>. </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=""><span class="searchResult" style="font-size: 1.1429em; background-color: rgba(255, 252, 141, 0.701961); border-top-left-radius: 6px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; color: rgb(34, 34, 34) !important;">Closure</span><span style="font-size: 1.1429em;" class="">s offer a structurally distinct class of syntactic sugar:</span><span style="font-size: 1.1429em;" class=""> </span></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="">You may elide parentheses (even with multiple arguments)</li><li style="font-size: 18px;" class="">You may omit the return type</li><li style="font-size: 18px;" class="">You may omit types</li><li style="font-size: 18px;" class="">You may omit the parameter list in its entirety</li></ul><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="">Short of a complete rethink of <span class="searchResult" style="background-color: rgba(255, 252, 141, 0.701961); border-top-left-radius: 6px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; color: rgb(34, 34, 34) !important; background-position: initial initial; background-repeat: initial initial;">closure</span> syntax, requiring parentheses there would not improve the language in any measurable way.</p></div></div>_______________________________________________<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></div></body></html>