<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’m -1 on this feature. Default values is basically compile sugar for not filling in the value at the call site. The protocol should clearly state its purpose and not constrain its implementations with stuff like this.</div><div class=""><br class=""></div><div class="">Also, the reason you’re getting “Good, Good” below is probably because default parameters are a bit of a “last resort” in overload resolution.</div><div class=""><br class=""></div><div class="">-Sune</div><br class=""><div><blockquote type="cite" class=""><div class="">On 16 Jan 2016, at 13:44, 肇鑫 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=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:georgia,serif">Hi Haravikk,</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif">I just implement a func like your examples. However, I find the result is interesting. </div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default"><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; color: rgb(187, 44, 162);" class="">protocol<span style="" class=""> Good {</span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""> <span style="color:rgb(187,44,162)" class="">func</span> printSomething(something:<span style="color:rgb(112,61,170)" class="">String</span>)</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; color: rgb(187, 44, 162);" class="">extension<span style="" class=""> </span><span style="color:rgb(79,129,135)" class="">Good</span><span style="" class=""> {</span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""> <span style="color:rgb(187,44,162)" class="">func</span> printSomething() { <span style="color:rgb(187,44,162)" class="">self</span>.<span style="color:rgb(49,89,93)" class="">printSomething</span>(<span style="color:rgb(209,47,27)" class="">"Good"</span>) }</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="color:rgb(187,44,162)" class="">struct</span> Name:<span style="color:rgb(79,129,135)" class="">Good</span> {</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""> <span style="color:rgb(187,44,162)" class="">func</span> printSomething(something: <span style="color:rgb(112,61,170)" class="">String</span> = <span style="color:rgb(209,47,27)" class="">"John"</span>) {</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""> <span style="color:rgb(61,29,129)" class="">print</span>(something)</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""> }</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="color:rgb(187,44,162)" class="">struct</span> Talk:<span style="color:rgb(79,129,135)" class="">Good</span> {</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""> <span style="color:rgb(187,44,162)" class="">func</span> printSomething(something: <span style="color:rgb(112,61,170)" class="">String</span> = <span style="color:rgb(209,47,27)" class="">"Hahaha"</span>) {</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""> <span style="color:rgb(61,29,129)" class="">print</span>(something)</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""> }</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="color:rgb(187,44,162)" class="">var</span> protocols:[<span style="color:rgb(79,129,135)" class="">Good</span>] = [<span style="color:rgb(79,129,135)" class="">Name</span>(), <span style="color:rgb(79,129,135)" class="">Talk</span>()]</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; color: rgb(79, 129, 135);" class=""><span style="color:rgb(187,44,162)" class="">for</span><span style="" class=""> p </span><span style="color:rgb(187,44,162)" class="">in</span><span style="" class=""> </span>protocols<span style="" class=""> {</span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class=""> p.</span><span style="color:rgb(49,89,93)" class="">printSomething</span><span style="" class="">() </span>// Good, Good instead of John, Hahaha</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class="">As you can see, the final result is "Good, Good", not as I expected "John, Hahaha", is that right or is it a bug?</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class="">zhaoxin </font></div></div></div></div></blockquote><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_default"><div style="margin: 0px; line-height: normal;" class="">[…snip…]</div></div></div></div></blockquote></div><div class=""><br class=""></div></body></html>