<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Hi Dave,</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">If you have read the whole list, you can find this proposal is trying to simplify a Protocol like:</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default"><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(187,44,162)">protocol<span style="color:rgb(0,0,0)"> A {</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">    <span style="color:rgb(187,44,162)">func</span> printSomething()</p>
<p 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>)</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">}</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><br></p><p style="margin:0px;line-height:normal;min-height:13px"><font face="georgia, serif">to</font></p><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><br></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(187,44,162)">protocol<span style="color:rgb(0,0,0)"> B {</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">    <span style="color:rgb(187,44,162)">func</span> printSomething(something:String = <span style="color:rgb(187,44,162)">default</span>) // default is a keyword, not a certain value, meaning the implementation must have a default parameter value</p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">}</p><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><br></p><p style="margin:0px;line-height:normal"><font face="georgia, serif">So that we can solve the previous talking bug. Protocol B can use both printSomething() and printSomething(&quot;john&quot;)</font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif"><br></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif">Currently, if we only have </font></p><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><br></p><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(187,44,162)">protocol<span style="color:rgb(0,0,0)"> C {</span></p><p 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>)</p><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">}</p><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><br></p><p style="margin:0px;line-height:normal"><font face="georgia, serif">We can not call printSomething() with protocol c. </font></p><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><br></p><p style="margin:0px;line-height:normal"><font face="georgia, serif">zhaoxin</font></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 17, 2016 at 9:51 AM,  <span dir="ltr">&lt;<a href="mailto:davesweeris@mac.com" target="_blank">davesweeris@mac.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"><br><div><span class=""><blockquote type="cite"><div>On Jan 16, 2016, at 17:28, 肇鑫 &lt;<a href="mailto:owenzx@gmail.com" target="_blank">owenzx@gmail.com</a>&gt; wrote:</div><br><div><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Hi Dave,</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Like you said, you approach does not solve the bug.</div><div class="gmail_default" style="font-family:georgia,serif"><br></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"><div style="font-size:13px">And this is the bug: If your protocol `Foo` has a function `foo(X)`, and your type has a function `foo(Y)` <i>where Y can be turned into X through the use of default parameters</i>, then it’s impossible for your type to conform to `Foo`, even though you could use it as a `Foo` in your code. In practice, I think this only matters if you’re using “macros” like <span style="color:rgb(187,44,162)">__LINE__</span> or something as your default parameter, but it’s still annoying (to me, anyway).</div><div><br></div></blockquote><div><br></div><div class="gmail_default" style="font-family:georgia,serif">​as this proposal does​.</div></div></div></blockquote><div><br></div></span><div>No, I was saying that (at least at a glance) I didn’t think the original proposal solved the problem I described, and that I thought my “counter” proposal would have all the functionality (albeit from the “other direction”) that Vatsal was proposing *and* fix the glitch.</div><div><br></div><div>…Maybe we’re saying the same thing.</div><span class=""><div><br></div><div><br></div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">I still think if we can call instance.function(), we should also call (instance as protocol).function(). If we can&#39;t, there must be something not right here.</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></blockquote></span></div><div><br></div>You can, as long as your protocol isn’t restricted to only being used as a generic constraint (no Self or typealiases):<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)">protocol<span style="color:#000000"> Foo {</span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:#bb2ca2">func</span> foo() -&gt; <span style="color:#703daa">String</span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)">extension<span style="color:#000000"> </span><span style="color:#703daa">Int</span><span style="color:#000000"> : </span><span style="color:#4f8187">Foo</span><span style="color:#000000"> {</span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:#bb2ca2">func</span> foo() -&gt; <span style="color:#703daa">String</span> { <span style="color:#bb2ca2">return</span> <span style="color:#d12f1b">&quot;lovely&quot;</span> }</div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">func</span> bar(x: <span style="color:#703daa">Any</span>) -&gt; <span style="color:#703daa">String</span> {</div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)"><span style="color:#000000">    </span><span style="color:#bb2ca2">if</span><span style="color:#000000"> x </span><span style="color:#bb2ca2">is</span><span style="color:#000000"> </span><span style="color:#4f8187">Foo</span><span style="color:#000000"> { </span><span style="color:#bb2ca2">return</span><span style="color:#000000"> </span>&quot;Here, have some <span style="color:#000000">\</span>(<span style="color:#000000">(x </span><span style="color:#bb2ca2">as</span><span style="color:#000000">! </span><span style="color:#4f8187">Foo</span><span style="color:#000000">).</span><span style="color:#31595d">foo</span><span style="color:#000000">()</span>) foo.&quot;<span style="color:#000000"> }</span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)"><span style="color:#000000">    </span><span style="color:#bb2ca2">else</span><span style="color:#000000">        { </span><span style="color:#bb2ca2">return</span><span style="color:#000000"> </span>&quot;NO FOO FOR YOU!!!&quot;<span style="color:#000000"> }</span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><div style="margin:0px;line-height:normal"><span style="color:#3d1d81">print</span><span style="color:#000000">(</span><span style="color:#31595d">bar</span><span style="color:#000000">(</span><span style="color:#272ad8">0</span><span style="color:#000000">))   </span>//Here, have some lovely foo.</div><div style="margin:0px;line-height:normal"><span style="color:#3d1d81">print</span><span style="color:#000000">(</span><span style="color:#31595d">bar</span><span style="color:#000000">(</span><span style="color:#d12f1b">&quot;&quot;</span><span style="color:#000000">))  </span>//NO FOO FOR YOU!!!</div><div><br></div></div></div></blockquote><div><div>- Dave Sweeris</div></div><div><br></div></div></blockquote></div><br></div>