<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-size:13px">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.</span></blockquote><div><br></div><div>I<div class="gmail_default" style="font-family:georgia,serif;display:inline">​ disagree. According to the definition of ​</div> <div class="gmail_default" style="font-family:georgia,serif;display:inline">​<a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Declarations.html#//apple_ref/swift/grammar/protocol-method-declaration">Protocol</a>.​</div></div><div><div class="gmail_default" style="font-family:georgia,serif;display:inline"><br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="color:rgb(65,65,65);font-family:Helvetica,Arial,sans-serif;font-size:14px">Protocol method declarations have the same form as function declarations, with two exceptions: They don’t include a function body, and you can’t provide any default parameter values as part of the function declaration. </span></blockquote><div><br></div><div class="gmail_default" style="font-family:georgia,serif">The definition doesn&#39;t say we can&#39;t use default values in implementation​. The definition doesn&#39;t say we can&#39;t declare that a function must have or have not default values. Only you can&#39;t set a default value in the protocol function declaration.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">This proposal is an improvement to the protocol and violate nothing. </div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">zhaoxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 19, 2016 at 12:53 AM, Sune Foldager <span dir="ltr">&lt;<a href="mailto:cyano@me.com" target="_blank">cyano@me.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>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><br></div><div>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><br></div><div>-Sune</div><br><div><span class=""><blockquote type="cite"><div>On 16 Jan 2016, at 13:44, 肇鑫 via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Hi Haravikk,</div><div class="gmail_default" style="font-family:georgia,serif"><br></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></div><div class="gmail_default"><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(187,44,162)">protocol<span> Good {</span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">    <span style="color:rgb(187,44,162)">func</span> printSomething(something:<span style="color:rgb(112,61,170)">String</span>)</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><br></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(187,44,162)">extension<span> </span><span style="color:rgb(79,129,135)">Good</span><span> {</span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">    <span style="color:rgb(187,44,162)">func</span> printSomething() { <span style="color:rgb(187,44,162)">self</span>.<span style="color:rgb(49,89,93)">printSomething</span>(<span style="color:rgb(209,47,27)">&quot;Good&quot;</span>) }</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><br></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="color:rgb(187,44,162)">struct</span> Name:<span style="color:rgb(79,129,135)">Good</span> {</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">    <span style="color:rgb(187,44,162)">func</span> printSomething(something: <span style="color:rgb(112,61,170)">String</span> = <span style="color:rgb(209,47,27)">&quot;John&quot;</span>) {</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">        <span style="color:rgb(61,29,129)">print</span>(something)</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">    }</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><br></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="color:rgb(187,44,162)">struct</span> Talk:<span style="color:rgb(79,129,135)">Good</span> {</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">    <span style="color:rgb(187,44,162)">func</span> printSomething(something: <span style="color:rgb(112,61,170)">String</span> = <span style="color:rgb(209,47,27)">&quot;Hahaha&quot;</span>) {</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">        <span style="color:rgb(61,29,129)">print</span>(something)</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">    }</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><br></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="color:rgb(187,44,162)">var</span> protocols:[<span style="color:rgb(79,129,135)">Good</span>] = [<span style="color:rgb(79,129,135)">Name</span>(), <span style="color:rgb(79,129,135)">Talk</span>()]</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><br></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(79,129,135)"><span style="color:rgb(187,44,162)">for</span><span> p </span><span style="color:rgb(187,44,162)">in</span><span> </span>protocols<span> {</span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,132,0)"><span>    p.</span><span style="color:rgb(49,89,93)">printSomething</span><span>() </span>// Good, Good instead of John, Hahaha</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><font face="georgia, serif">As you can see, the final result is &quot;Good, Good&quot;, not as I expected &quot;John, Hahaha&quot;, is that right or is it a bug?</font></div><div style="margin:0px;line-height:normal"><font face="georgia, serif"><br></font></div><div style="margin:0px;line-height:normal"><font face="georgia, serif">zhaoxin    </font></div></div></div></div></blockquote><br></span><blockquote type="cite"><div><div dir="ltr"><div class="gmail_default"><div style="margin:0px;line-height:normal">[…snip…]</div></div></div></div></blockquote></div><div><br></div></div></blockquote></div><br></div>