<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 Apr 18, 2016, at 11:08 AM, Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On Sun, Apr 17, 2016 at 11:10 AM, Matthew Johnson via swift-evolution<br class="">&lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><blockquote type="cite" class="">These extension points are effectively “optional protocol requirements”.<br class=""></blockquote><br class="">I'm sorry, but they are not optional requirements. &nbsp;They are<br class="">workarounds for a language issue -- inability to make<br class="">conditionally-available methods customizable by a conforming type.<br class=""></div></div></blockquote><div><br class=""></div><div>I understand that they are not optional requirements as they exist in the language today. &nbsp;What I meant is that the approach these extension points are taking is effectively the same as one of the approaches discussed in the "How to eliminate 'optional' protocol<span class="Apple-tab-span" style="white-space: pre;">        </span>requirements” thread. &nbsp;</div><div><br class=""></div><div>I am referring to the first option in Doug’s initial message: <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160404/014471.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160404/014471.html</a>. &nbsp;Doug considered this unworkable but Joe considers the reasons Doug called it unworkable to be missing language features that should exist anyway: <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160411/014696.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160411/014696.html</a>. &nbsp;There has not yet been a resolution on this issue.</div><div><br class=""></div><div>The primary difference between that approach and your extension points is that you add and extra level of optionality to the value returned whereas the approach in that thread has an optional closure property. &nbsp;Both approaches use a default implementation of “return nil” to indicate that there is no customization requested by the implementer.</div><div><br class=""></div><div>In your proposal the extension points look like this:</div><div><br class=""></div><div><pre class=" language-swift" style="word-spacing: normal; -webkit-print-color-adjust: exact; margin-top: 0.5em; margin-bottom: 0.5em; background-color: rgb(245, 242, 240); border: 1px solid rgb(204, 204, 204); font-size: 13px; line-height: 1.5; overflow: auto; padding: 1em; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; text-shadow: white 0px 1px; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; word-break: normal; word-wrap: normal; tab-size: 4; -webkit-hyphens: none;"><code class=" language-swift" style="-webkit-print-color-adjust: exact; margin: 0px; padding: 0px; border: none; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-image: none; text-shadow: white 0px 1px; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; word-spacing: normal; word-break: normal; word-wrap: normal; line-height: 1.5; tab-size: 4; -webkit-hyphens: none;"><span class="token keyword" style="-webkit-print-color-adjust: exact; color: rgb(0, 119, 170);">func</span> <span class="token function" style="-webkit-print-color-adjust: exact; color: rgb(221, 74, 104);">_customMinComparableElement</span><span class="token punctuation" style="-webkit-print-color-adjust: exact; color: rgb(153, 153, 153);">(</span><span class="token punctuation" style="-webkit-print-color-adjust: exact; color: rgb(153, 153, 153);">)</span> <span class="token operator" style="-webkit-print-color-adjust: exact; color: rgb(166, 127, 89); background-color: rgba(255, 255, 255, 0.498039);">-</span><span class="token operator" style="-webkit-print-color-adjust: exact; color: rgb(166, 127, 89); background-color: rgba(255, 255, 255, 0.498039);">&gt;</span> <span class="token builtin" style="-webkit-print-color-adjust: exact; color: rgb(102, 153, 0);">Iterator</span><span class="token punctuation" style="-webkit-print-color-adjust: exact; color: rgb(153, 153, 153);">.</span><span class="token builtin" style="-webkit-print-color-adjust: exact; color: rgb(102, 153, 0);">Element</span><span class="token operator" style="-webkit-print-color-adjust: exact; color: rgb(166, 127, 89); background-color: rgba(255, 255, 255, 0.498039);">?</span><span class="token operator" style="-webkit-print-color-adjust: exact; color: rgb(166, 127, 89); background-color: rgba(255, 255, 255, 0.498039);">?</span></code></pre><div class=""><br class=""></div><div class="">Translating to the option Doug presented they would look like this:</div><div class=""><br class=""></div><div class=""><pre class=" language-swift" style="word-spacing: normal; -webkit-print-color-adjust: exact; margin-top: 0.5em; margin-bottom: 0.5em; background-color: rgb(245, 242, 240); border: 1px solid rgb(204, 204, 204); font-size: 13px; line-height: 1.5; overflow: auto; padding: 1em; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; text-shadow: white 0px 1px; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; word-break: normal; word-wrap: normal; tab-size: 4; -webkit-hyphens: none;"><code class=" language-swift" style="-webkit-print-color-adjust: exact; margin: 0px; padding: 0px; border: none; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-image: none; text-shadow: white 0px 1px; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; word-spacing: normal; word-break: normal; word-wrap: normal; line-height: 1.5; tab-size: 4; -webkit-hyphens: none;"><span class="token keyword" style="-webkit-print-color-adjust: exact; color: rgb(0, 119, 170);">var</span> <span class="token function" style="-webkit-print-color-adjust: exact; color: rgb(221, 74, 104);">_customMinComparableElement: (</span><span class="token punctuation" style="-webkit-print-color-adjust: exact; color: rgb(153, 153, 153);">(</span><span class="token punctuation" style="-webkit-print-color-adjust: exact; color: rgb(153, 153, 153);">)</span> <span class="token operator" style="-webkit-print-color-adjust: exact; color: rgb(166, 127, 89); background-color: rgba(255, 255, 255, 0.498039);">-</span><span class="token operator" style="-webkit-print-color-adjust: exact; color: rgb(166, 127, 89); background-color: rgba(255, 255, 255, 0.498039);">&gt;</span> <span class="token builtin" style="-webkit-print-color-adjust: exact; color: rgb(102, 153, 0);">Iterator</span><span class="token punctuation" style="-webkit-print-color-adjust: exact; color: rgb(153, 153, 153);">.</span><span class="token builtin" style="-webkit-print-color-adjust: exact; color: rgb(102, 153, 0);">Element</span><span class="token operator" style="-webkit-print-color-adjust: exact; color: rgb(166, 127, 89); background-color: rgba(255, 255, 255, 0.498039);">?)</span><span class="token operator" style="-webkit-print-color-adjust: exact; color: rgb(166, 127, 89); background-color: rgba(255, 255, 255, 0.498039);">? { get }</span></code></pre><div class=""><br class=""></div></div></div><div>In either case a default implementation that returns nil would be provided. &nbsp;Under Doug’s model where methods can be used to implement such requirements, implementers would provide a method like this:</div><div><br class=""></div><div><pre class=" language-swift" style="word-spacing: normal; -webkit-print-color-adjust: exact; margin-top: 0.5em; margin-bottom: 0.5em; background-color: rgb(245, 242, 240); border: 1px solid rgb(204, 204, 204); font-size: 13px; line-height: 1.5; overflow: auto; padding: 1em; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; text-shadow: white 0px 1px; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; word-break: normal; word-wrap: normal; tab-size: 4; -webkit-hyphens: none;"><code class=" language-swift" style="-webkit-print-color-adjust: exact; margin: 0px; padding: 0px; border: none; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-image: none; text-shadow: white 0px 1px; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; word-spacing: normal; word-break: normal; word-wrap: normal; line-height: 1.5; tab-size: 4; -webkit-hyphens: none;"><span class="token function" style="-webkit-print-color-adjust: exact; color: rgb(221, 74, 104);">func _customMinComparableElement</span><span class="token punctuation" style="-webkit-print-color-adjust: exact; color: rgb(153, 153, 153);">(</span><span class="token punctuation" style="-webkit-print-color-adjust: exact; color: rgb(153, 153, 153);">)</span> <span class="token operator" style="-webkit-print-color-adjust: exact; color: rgb(166, 127, 89); background-color: rgba(255, 255, 255, 0.498039);">-</span><span class="token operator" style="-webkit-print-color-adjust: exact; color: rgb(166, 127, 89); background-color: rgba(255, 255, 255, 0.498039);">&gt;</span> <span class="token builtin" style="-webkit-print-color-adjust: exact; color: rgb(102, 153, 0);">Iterator</span><span class="token punctuation" style="-webkit-print-color-adjust: exact; color: rgb(153, 153, 153);">.</span><span class="token builtin" style="-webkit-print-color-adjust: exact; color: rgb(102, 153, 0);">Element</span><span class="token operator" style="-webkit-print-color-adjust: exact; color: rgb(166, 127, 89); background-color: rgba(255, 255, 255, 0.498039);">?</span></code></pre><div class=""><br class=""></div></div><div>I hope I have clarified how I believe these extension points are related to the thread about removing optional protocol requirements from the language. &nbsp;My opinion is that if we are going to remove them and import them from Objective-C in a more Swifty way by embedding the optionality in the type system that same mechanism should be used by any extension points which behave similarly.</div><div><br class=""></div><div>Matthew</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div class=""><br class="">Dmitri<br class=""><br class="">-- <br class="">main(i,j){for(i=2;;i++){for(j=2;j&lt;i;j++){if(!(i%j)){j=0;break;}}if<br class="">(j){printf("%d\n",i);}}} /*Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>&gt;*/<br class=""></div></div></blockquote></div><br class=""></body></html>