<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=""><br class=""><div><blockquote type="cite" class=""><div class="">Le 7 juin 2017 à 12:03, Adrian Zubarev via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><p style="margin: 15px 0px; -webkit-margin-before: 0px; font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Well please no:</p><p style="margin: 15px 0px; font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<code style="font-family: Menlo, Consolas, 'Liberation Mono', Courier, monospace; font-size: 10pt; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(248, 248, 248); color: inherit; border: 1px solid rgb(234, 234, 234); margin: 0px 2px; padding: 0px 5px; word-break: normal; word-wrap: normal; -webkit-margin-before: 0px;" class=""><span class="Apple-converted-space"> </span>let fn2: ((Int, Int)) -> Void = { lhs, rhs in }<span class="Apple-converted-space"> </span></code></p><p style="margin: 15px 0px; font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Instead use destructuring sugar pitched by Chris Lattner on the other thread:</p><p style="margin: 15px 0px; font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><code style="font-family: Menlo, Consolas, 'Liberation Mono', Courier, monospace; font-size: 10pt; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(248, 248, 248); color: inherit; border: 1px solid rgb(234, 234, 234); margin: 0px 2px; padding: 0px 5px; word-break: normal; word-wrap: normal; -webkit-margin-before: 0px;" class="">let fn2: ((Int, Int)) -> Void = { ((lhs, rhs)) in }</code></p></div></blockquote></div><br class=""><div class=""><div class=""><div class=""><div class="">Despite Chris Lattern being a semi-god, his double-parenthesis suggestion cruelly lacks in terms of user ergonomics. The compiler should be able to deal with the following code snippet, just like Swift 3 does:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// two arguments</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> f1(</span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> closure: (</span><span style="font-variant-ligatures: no-common-ligatures; color: #3c59a7" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #3c59a7" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">) -> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3c59a7" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">) { closure(1, 2) }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f1</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { lhs, rhs </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> lhs + rhs }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f1</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { (lhs, rhs) </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> lhs + rhs }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f1</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { tuple </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> tuple.0 + tuple.1 }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f1</span><span style="font-variant-ligatures: no-common-ligatures" class="">(+)</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// two arguments, with documentation names</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> f2(</span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> closure: (</span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> a: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3c59a7" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> b: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3c59a7" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">) -> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3c59a7" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">) { closure(1, 2) }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f2</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { lhs, rhs </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> lhs + rhs }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f2</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { (lhs, rhs) </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> lhs + rhs }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f2</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { tuple </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> tuple.0 + tuple.1 }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f2</span><span style="font-variant-ligatures: no-common-ligatures" class="">(+)</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// one tuple argument</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> f3(</span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> closure: ((</span><span style="font-variant-ligatures: no-common-ligatures; color: #3c59a7" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #3c59a7" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">)) -> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3c59a7" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">) { closure((1, 2)) }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f3</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { lhs, rhs </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> lhs + rhs }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f3</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { (lhs, rhs) </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> lhs + rhs }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f3</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { tuple </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> tuple.0 + tuple.1 }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f3</span><span style="font-variant-ligatures: no-common-ligatures" class="">(+)</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// one keyed tuple argument</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> f4(</span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> closure: ((a: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3c59a7" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">, b: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3c59a7" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">)) -> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3c59a7" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">) { closure((a: 1, b: 2)) }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f4</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { lhs, rhs </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> lhs + rhs }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f4</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { (lhs, rhs) </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> lhs + rhs }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f4</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { tuple </span><span style="font-variant-ligatures: no-common-ligatures; color: #8135a0" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> tuple.a + tuple.b }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f4</span><span style="font-variant-ligatures: no-common-ligatures" class="">(+)</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></div><div class="">This covers the Swift 3 regressions developped by Stephen Celis and I, unless I have missed any. And this should be the goal of the designers of this language, *regardless of the actual types*. Developers are olding their breath: please just make this happen.</div><div class=""><br class=""></div><div class="">Now Swift 3 may have an issue with $n parameters. Here is my suggestion, should `((Int, Int)) -> Int` be different from `(Int, Int) -> Int`:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f1</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { $0 + $1 } </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f00" class="">// OK</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f1</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> { $0.0 + $0.1 } </span><span style="font-variant-ligatures: no-common-ligatures" class="">// OK in Swift 3, compiler error in Swift 4?</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f2</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { $0 + $1 } </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f00" class="">// OK</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f2</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> { $0.0 + $0.1 } </span><span style="font-variant-ligatures: no-common-ligatures" class="">// OK in Swift 3, compiler error in Swift 4?</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f3</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> { $0 + $1 } </span><span style="font-variant-ligatures: no-common-ligatures" class="">// OK in Swift 3, compiler error in Swift 4?</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f3</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { $0.0 + $0.1 } </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f00" class="">// OK</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f4</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> { $0 + $1 } </span><span style="font-variant-ligatures: no-common-ligatures" class="">// OK in Swift 3, compiler error in Swift 4?</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #20809f" class="">f4</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { $0.a + $0.b } </span><span style="font-variant-ligatures: no-common-ligatures; color: #008f00" class="">// OK</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures; color: #008f00" class=""><br class=""></span></div></div><div class="">Gwendal Roué</div><div class=""><br class=""></div></div></div></div></body></html>