<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">This is similar to another concern I raised with functions and being able to essentially erase the function argument names and apply two different named parameters just because their types match.<div class=""><br class=""></div><div class="">It seems reasonable to me that you can go from (x: Int, y: Int) =&gt; (Int, Int). However, going from (x: Int, y: Int) =&gt; (a: Int, b: Int) feels somewhat odd. Yes, the types can obviously slot in there fine, but how much importance do the labels for the types bring to the table?</div><div class=""><br class=""></div><div class="">Similarly, should this (Int, Int) =&gt; (x: Int, y: Int) be allowed through an implicit means? If so, then it's really just an intermediate step for (x: Int, y: Int) =&gt; (a: Int, b: Int) working.</div><div class=""><br class=""></div><div class="">So what matters more, type signatures or label names?</div><div class=""><br class=""></div><div class="">Here's an example:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">typealias&nbsp;Functor = (left:&nbsp;Int, right:&nbsp;Int) -&gt;&nbsp;Int</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">func&nbsp;hi(x:&nbsp;Int, y:&nbsp;Int, fn:&nbsp;Functor) -&gt;&nbsp;Int&nbsp;{</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;return&nbsp;fn(left: x, right: y)</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">hi(1, y:&nbsp;2, fn: +)</font></div><div class=""><font face="Menlo" class="">hi(1, y:&nbsp;2, fn: *)</font></div></blockquote><div class=""><br class=""></div><div class="">If we say that the parameter names are indeed vital, then the above code cannot work as the operators that match the type signature are defined as:&nbsp;</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">public&nbsp;func&nbsp;+(lhs:&nbsp;Int, rhs:&nbsp;Int) -&gt;&nbsp;Int</font></div></blockquote><div class=""><br class=""></div><div class="">Obviously, given a name to the parameter brings clarity and can be self documenting, but if we want the above to work while making names just as vital as the type signature, then we need to declare `Functor` as such:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><font face="Menlo" class="">typealias&nbsp;Functor = (_ left:&nbsp;Int, _ right:&nbsp;Int) -&gt;&nbsp;Int</font></div></div></blockquote><div class=""><br class=""></div><div class="">However, that's not even legal code today, and even if it were, is that really better?</div><div class=""><br class=""></div><div class="">So I'm mixed on the idea. I think the idea that type coercions happening for matching type signatures is very powerful, and this just happens to be one of the example manifestations of that.</div><div class=""><br class=""></div><div class="">-David</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 20, 2016, at 6:23 AM, Adrian Zubarev via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><div id="bloop_customfont" style="margin: 0px;" class="">I would like to discuss about the following topic.</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class="">Wouldn't it be better to enforce argument labels on tuples types, if the tuple type defines them?</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class="">```swift</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class="">func foo(tuple: (a: Int, b: Int)) { /* do something */ }</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class="">let test1 = (10, 100)</div><div id="bloop_customfont" style="margin: 0px;" class="">let test2: (a: Int, c: Int) = test</div><div id="bloop_customfont" style="margin: 0px;" class="">let test3: (Int, Int) = test2</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class="">foo(test1)</div><div id="bloop_customfont" style="margin: 0px;" class="">foo(test3)</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class="">/*</div><div id="bloop_customfont" style="margin: 0px;" class="">cannot convert value of type '(a: Int, c: Int)'&nbsp;</div><div id="bloop_customfont" style="margin: 0px;" class="">to expected argument type '(a: Int, b: Int)'</div><div id="bloop_customfont" style="margin: 0px;" class="">*/</div><div id="bloop_customfont" style="margin: 0px;" class="">foo(test2)&nbsp;</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class="">```</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class="">Function `foo` awaits a tuple of type `(a: Int, b: Int)` but `test1` and `test3` are both just of type `(Int, Int)`.</div><div id="bloop_customfont" style="margin: 0px;" class="">As expected `test2` will raise an error because it has indeed a wrong type `(a: Int, c: Int)`.</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class="">I'd suggest to enforce argument labeling on tuple types for better readability, because wasn't it the idea behind labels inside tuples?</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class="">`foo(test1)` should raise an error `cannot convert value of type '(Int, Int)' to expected argument type '(a: Int, b: Int)'` as long as `test1` is not written like `let test1 = (a: 10, b: 100)` or `let test1: (a: Int, b: Int) = (a: 10, b: 100)`</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class="">This will impact current codebase if you used labels but provided tuples without labels like the example above. The migrator could solve this by providing labels automatically to tuples where this error occurs.</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class="">I'm not good at writing proposals for the GitHub repository at all, so if the community likes this idea, I'd be glad to see some help for this little proposal.</div></div><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div id="bloop_sign_1461158299115177984" class="bloop_sign" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="font-family: helvetica, arial; font-size: 13px;" class="">--&nbsp;<br class="">Adrian Zubarev<br class="">Sent with Airmail</div></div><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></body></html>