<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="">I don’t think it is possible to implement this without major changes to the way function overloads are selected.<div class=""><br class=""></div><div class="">Consider the following example with where there are multiple functions that can print a Double (yes, the external arguments could be put in the function’s name, but I hope it shows my point):</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; color: #bb2ca2" class="">func</span> myPrint(number:&nbsp;<span style="color: rgb(112, 61, 170);" class="">Double</span>)&nbsp;{ }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> myPrint(withTwoDecimals number:&nbsp;<span style="color: rgb(112, 61, 170);" class="">Double</span>)&nbsp;{ }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> myPrint(withThreeDecimals number:&nbsp;<span style="color: rgb(112, 61, 170);" class="">Double</span>)&nbsp;{ }</div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-family: Helvetica; font-size: 13px;" class="">Currently all three of these functions have different signatures. If your syntax would be implemented in Swift, then</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-family: Helvetica; font-size: 13px;" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">myPrint</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>withTwoDecimals<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-family: Helvetica; font-size: 13px;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Helvetica; font-size: 13px;" class="">would be&nbsp;</span>ambiguous.&nbsp;</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Defaulting to the function without external parameter names in case of ambiguity isn’t an option because then the call would change its behaviour the moment a library adds&nbsp;<span style="font-family: Menlo; font-size: 11px;" class="">myPrint(number:&nbsp;</span><span style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);" class="">Double</span><span style="font-family: Menlo; font-size: 11px;" class="">)&nbsp;</span>in addition to the other functions. This is definitely not desirable! The same applies for defaulting to the function with the external parameter name.</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">I don’t like leaving the function call ambiguous because then the only way to call&nbsp;<span style="font-family: Menlo; font-size: 11px;" class="">myPrint(number:&nbsp;</span><span style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);" class="">Double</span><span style="font-family: Menlo; font-size: 11px;" class="">)&nbsp;</span>would be to change the name of the variable. The name of any variable should by private and therefore not have any effect on how the function is called. (Also think about functions where there is basically only one proper way to name a variable, like x for coordinates. You would have to rename the variable which leads to less descriptive variable names).</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Thus, the only way to resolve this issue IMO would be to say that the signatures&nbsp;<span style="font-family: Menlo; font-size: 11px;" class="">myPrint(number:&nbsp;</span><span style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);" class="">Double</span><span style="font-family: Menlo; font-size: 11px;" class="">)&nbsp;</span>and&nbsp;<span style="font-family: Menlo; font-size: 11px;" class="">myPrint(withTwoDecimals number:&nbsp;</span><span style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);" class="">Double</span><span style="font-family: Menlo; font-size: 11px;" class="">)&nbsp;</span>are identical. Then, however, the signatures of&nbsp;<span style="font-family: Menlo; font-size: 11px;" class="">myPrint(withTwoDecimals number:&nbsp;</span><span style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);" class="">Double</span><span style="font-family: Menlo; font-size: 11px;" class="">)</span>&nbsp;and&nbsp;<span style="font-family: Menlo; font-size: 11px;" class="">myPrint(withThreeDecimals number:&nbsp;</span><span style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);" class="">Double</span><span style="font-family: Menlo; font-size: 11px;" class="">)</span>&nbsp;would need to be equivalent as well, which seriously limits the way functions can be overloaded in Swift. I don’t think that the improved syntax is worth paying with the this expressiveness of function overloads.</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">- Alex</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 07 Feb 2016, at 20:45, Kenny Leung 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 class="">Hi All.<br class=""><br class="">I’m just throwing this out there.<br class=""><br class="">often when I write Objective-C, my method calls end up looking like this:<br class=""><br class="">[you doYourThingWithThis:this that:that these:these those:those other:other];<br class=""><br class="">This reads poorly and requires extra typing. It would be nice if the compiler just assumed that when no label is given, the label is the same as the argument name. The code would be just as understandable (more) than if the argument labels were actually there.<br class=""><br class="">In Swift, this:<br class=""><br class="">you.doYourThingWithThis(this, that:that, these:these, those:those, other:other)<br class=""><br class="">becomes<br class=""><br class="">you.doYourThingWithThis(this, that, these, those, other)<br class=""><br class="">However, if you are the type that likes to name your variables a,b,c,d, no harm done, since then labels would be required, and it would still read OK<br class=""><br class="">you.doYourThingWithThis(a, that:b, these:c, those:d, other:e)<br class=""><br class="">-Kenny<br class=""><br class="">_______________________________________________<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></div></blockquote></div><br class=""></div></body></html>