<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 16, 2016, at 17:28, 肇鑫 <<a href="mailto:owenzx@gmail.com" class="">owenzx@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:georgia,serif">Hi Dave,</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></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 class=""></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" class="">And this is the bug: If your protocol `Foo` has a function `foo(X)`, and your type has a function `foo(Y)` <i class="">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)" class="">__LINE__</span> or something as your default parameter, but it’s still annoying (to me, anyway).</div><div class=""><br class=""></div></blockquote><div class=""><br class=""></div><div class="gmail_default" style="font-family:georgia,serif">as this proposal does.</div></div></div></blockquote><div><br class=""></div><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 class=""></div><div>…Maybe we’re saying the same thing.</div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><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't, there must be something not right here.</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif">zhaoxin</div></div></div></blockquote></div><div class=""><br class=""></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;" class=""><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">protocol<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> Foo {</span></div></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> foo() -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">extension<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> : </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Foo</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div></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> foo() -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span> { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"lovely"</span> }</div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div></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> bar(x: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Any</span>) -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span> {</div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> x </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">is</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Foo</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> { </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>"Here, have some <span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(x </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">as</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">! </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Foo</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">).</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">foo</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">()</span>) foo."<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> }</span></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">else</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> { </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>"NO FOO FOR YOU!!!"<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> }</span></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">bar</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)) </span>//Here, have some lovely foo.</div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">bar</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">""</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)) </span>//NO FOO FOR YOU!!!</div><div class=""><br class=""></div></div></div></blockquote><div class=""><div class="">- Dave Sweeris</div></div><div class=""><br class=""></div></body></html>