<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>This is an interesting idea. Here's another (I'm just spitballing here):</div><div><br></div><div>Extension methods without a requirement must be marked with a @nonrequired attribute (names are all provisional).</div><div><br></div><div>If a requirement is later added to a protocol with the name of a previously declared nonrequired method, an extension must also be declared marking those method names @required:</div><div><br></div><div>protocol Foo { }</div><div>extension Foo {</div><div>&nbsp; @nonrequired func blah(x: Int) {&nbsp;</div><div>&nbsp; &nbsp; &nbsp;print(x + 100)</div><div>&nbsp; }</div><div>}</div><div><br></div><div>Later:</div><div><br></div><div>protocol FooChild : Foo {</div><div>&nbsp; func blah(x: Int)</div><div>}</div><div><br></div><div>// requires to compile</div><div>extension FooChild {</div><div>&nbsp; @required blah(x:)</div><div>}</div><div><br></div><div>The only point of this would be to allow it to be made clear to users whether that protocol method is a requirement or not after extensions and retroactive modeling have occurred, and thus help them reason about whether it would be statically or dynamically dispatched.&nbsp;</div><div><br>Austin<br><br><div>Sent from my iPhone</div></div><div><br>On May 22, 2016, at 12:53 PM, Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><br class=""><div><blockquote type="cite" class=""><div class="">On May 22, 2016, at 12:36 PM, L. Mihalkovic &lt;<a href="mailto:laurent.mihalkovic@gmail.com" class="">laurent.mihalkovic@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">On May 22, 2016, at 5:31 PM, Matthew Johnson &lt;<a href="mailto:matthew@anandabits.com" class="">matthew@anandabits.com</a>&gt; wrote:<br class=""><br class=""><br class=""><br class="">Sent from my iPad<br class=""><br class=""><blockquote type="cite" class="">On May 22, 2016, at 8:39 AM, L. Mihalkovic &lt;<a href="mailto:laurent.mihalkovic@gmail.com" class="">laurent.mihalkovic@gmail.com</a>&gt; wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">On May 22, 2016, at 3:15 PM, Matthew Johnson &lt;<a href="mailto:matthew@anandabits.com" class="">matthew@anandabits.com</a>&gt; wrote:<br class=""><br class=""><br class=""><br class="">Sent from my iPad<br class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">On May 22, 2016, at 1:49 AM, Vladimir.S via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">On 22.05.2016 3:01, L. Mihalkovic via swift-evolution wrote:<br class="">Read the proposal... I have an aversion to-go coffee cups that remind<br class="">people that hot coffee may burn them, and when my daughter was 4 we<br class="">explained to her why knives were to be handled with care, rather than<br class="">remove them all from her sight. IMHO the proposal evoques mandating<br class="">training wheels rather than letting people learn naturally from their<br class="">errors.<br class=""></blockquote><br class="">I can partially support this opinion. But we have a situation with protocol extension methods and static dispatches in which we need Swift's help on compilation stage. IMO Using your words, right now we just got knife in our hands *without* any explanation. Then we hurt ourselves, and *then* we know that such methods will be dispatched statically(and the rule of dispatch is quite non-obvious). This is another extreme like "remove all knives". We need some golden middle. Personally I believe the solution is in compiler warning and in some method to 'fix' this warning.<br class=""></blockquote><br class="">Why not just make it an error and require an annotation on the extension methods?<br class=""></blockquote><br class="">See &nbsp;&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160516/018560.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160516/018560.html</a><br class="">And &nbsp;&nbsp;<a href="https://github.com/lmihalkovic/swift-lang/tree/master/Dispatching.playground" class="">https://github.com/lmihalkovic/swift-lang/tree/master/Dispatching.playground</a><br class=""></blockquote><br class="">That doesn't answer my question. &nbsp;I don't like any of the suggestions you posted. &nbsp;I think we should just leave the behavior as is (at least for now) and just require annotations on non-default methods in protocol extensions (making it an error to declare a non-default method without the annotation).<br class=""><br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Considering how things work fine the way they are today once THEIR logic is understood (the only problem today seems to be one of expectations mismatch, not that something is broken or illogic), it would IMHO be a waste of energy to revisit only to end up with a system that would only support a single model. It something is done, it might as well be to add freedom.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">So if you make it optional to have an attribute (I seem to recall chris explicitely saying that annotations were not the idiomatic swift way to convey these types of behavirial adjustments) on non required extension methods, then what you describe is basically one of the proposals I listed.. </span></div></blockquote><div><br class=""></div><div>It would be pointless for this to be optional. &nbsp;The whole point is to have the code reflect the fact that the dispatch semantics are likely to be surprising until you learn the rules (and also if you forget to consider them), and to always keep this fact in our minds as we work with protocol extensions.</div><div><br class=""></div><div>Which of your proposals do you think this matches?</div><div><br class=""></div><div>1. `override` in implementing classes.</div><div>2. `straw_man_dynamic_dispatch` at call site.</div><div>3. `straw_man_dynamic_dispatch` at declaration site in protocol extension.</div><div>4. doesn’t make sense (we are never going to statically dispatch protocol requirements and we can’t dynamically non-required extension methods in Swift 3)</div><div>5. `<span style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">straw_man_default_attribute` on default methods in protocol extensions.</span></div><div><span style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class=""><br class=""></span></div><div><span style="background-color: rgb(255, 255, 255);" class=""><span style="white-space: pre-wrap;" class="">None of these are what I suggest.  What I suggest is that we leave behavior alone and we *don’t* annotate default implementations because those don’t surprise anyone.  I suggest requiring this:</span></span></div><div><span style="background-color: rgb(255, 255, 255);" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></span></div><div><span style="background-color: rgb(255, 255, 255);" class=""><span style="white-space: pre-wrap;" class="">`</span></span><span style="white-space: pre-wrap;" class="">straw_man_static_dispatch` at declaration site of non-default methods in protocol extensions. &nbsp;</span></div><div><span style="white-space: pre-wrap;" class=""><br class=""></span></div><div><span style="white-space: pre-wrap;" class="">The only question is what actual modifier we use (`final` and `nondynamic` are obvious candidates, but both are non-starters in my mind for reasons I have stated earlier).</span></div><div class=""><br class=""></div><div class="">I do think it would be a good idea to introduce this in Swift 3 as it is a breaking change.&nbsp;</div><div class=""><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">for a simple reason mind you... what I listed is what I saw people debate. A few options were left out as being too complex to summarize, or not ringing true to what exists today and what has been explained about protocols with great clarity by Dave on stage at WWDC. Interestingly enough, the idea of default methods on the protocol itself (which I like in java8) was already listed by him and at least someone else in the compiler team.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Coming from working in asm, c, c++, perl, tcl, vb, java, c#, js, objc, scala, typescript and go in that order, I can get used to anything as long as its logic seems reasonable and adequately explained. &nbsp;After reading so many emails I thought I might not be the only one craving a simple one page summary of what had been said so far.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""><blockquote type="cite" class=""><br class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><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=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></blockquote></blockquote></blockquote></blockquote></div></blockquote></div><br class=""></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>