<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><style type="text/css">body { background: rgba(255, 255, 255, 255); }</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Good day, swift community!<div class="">This time, I'd like to bring your attention to an everyday problem which, I'm sure, you've all dealt with at some point.</div><div class=""><br class=""></div><div class=""><b class="">Motivation</b></div><div class=""><br class=""></div><div class="">Many protocols have a lot of default-implemented requirements so that they can be customized, which would otherwise be impossible to do.</div><div class="">For example, the <font color="#4f7a28" face="Menlo" class="">Comparable</font> protocol, which (considering its inheritance of <font face="Menlo" color="#4f7a28" class="">Equatable</font>) states a requirement of <font face="Menlo" class="">==</font>, <font face="Menlo" class="">!=</font>, <font face="Menlo" class="">&lt;</font>, <font face="Menlo" class="">&lt;=</font>, <font face="Menlo" class="">&gt;</font>, and <font face="Menlo" class="">&gt;=</font>, only requires implementation of&nbsp;<font face="Menlo" class="">==</font>&nbsp;and <font face="Menlo" class="">&lt;</font>, because all others have default implementations in terms of these two. This forces the user to either memorize the exact set of mandatory requirements or, in case of more complicated protocols like <font face="Menlo" color="#4f7a28" class="">Collection</font>, constantly look up the documentation and hope that it has a section outlining how to conform to it.</div><div class="">Conversely, the author of the protocol needs to manually keep track of the requirements and their default implementations to ensure that the ones that have to be mandatory stay mandatory and the rest of the requirements stay default-implemented, which is also a tedious and error-prone work.</div><div class=""><br class=""></div><div class=""><b class="">Proposed Solution</b></div><div class=""><br class=""></div><div class="">I'd like to propose the ability to mark select protocol requirements as <font color="#b92d5d" face="Menlo" class="">default</font>, which would cause the following effects:</div><div class=""><ul class="MailOutline"><li class="">The compiler will emit a compile-time error if a default implementation is not available in a non-constrained protocol extension in the same file and provide a fix-it for inserting a template.</li><li class="">If a conforming type does not implement all requirements of the protocol, the compiler will not produce fix-its for inserting a template for any <font color="#b92d5d" face="Menlo" class="">default</font> requirements.</li></ul></div><div class=""><br class=""></div><div class=""><b class="">Example</b></div><div class=""><br class=""></div><div class=""><font face="Menlo" color="#7a7a7a" class="">// Equatable.swift</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><font color="#b92d5d" class="">protocol</font> <font color="#4f7a28" class="">Equatable</font> {</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><font color="#b92d5d" class="">static</font> <font color="#b92d5d" class="">func</font> == (_ some: <font color="#b92d5d" class="">Self</font>, _ other: <font color="#b92d5d" class="">Self</font>) -&gt; <font color="#4f7a28" class="">Bool</font></font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><font color="#b92d5d" class="">default</font> <font color="#b92d5d" class="">static</font> <font color="#b92d5d" class="">func</font> != (_ some: <font color="#b92d5d" class="">Self</font>, _ other: <font color="#b92d5d" class="">Self</font>) -&gt; <font color="#4f7a28" class="">Bool</font></font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span></font><font color="#e32400" class=""><i class=""><font style="font-family: Menlo;" class="">^ error: missing implementation of a default requirement `!=`;&nbsp;</font><font style="font-family: Menlo;" class="">fix-it: insert a default implementation</font></i></font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><font color="#b92d5d" class="">extension</font> <font color="#4f7a28" class="">Equatable</font> {</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></font><font color="#b92d5d" face="Menlo" class="">static</font><span style="font-family: Menlo;" class="">&nbsp;</span><font color="#b92d5d" face="Menlo" class="">func</font><span style="font-family: Menlo;" class="">&nbsp;!= (_ some:&nbsp;</span><font color="#9a244f" style="font-family: Menlo;" class="">Self</font><span style="font-family: Menlo;" class="">, _ other:&nbsp;</span><font color="#9a244f" style="font-family: Menlo;" class="">Self</font><span style="font-family: Menlo;" class="">) -&gt;&nbsp;</span><font color="#4f7a28" face="Menlo" class="">Bool</font><font face="Menlo" class=""> {</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space:pre">                </span><b class="">[<font color="#4d22b3" class="">Your Code Here]</font></b></font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" color="#929292" class="">// Something.swift</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><font color="#b92d5d" class="">struct</font> <font color="#4f7a28" class="">Something</font>: <font color="#4f7a28" class="">Equatable</font> {</font></div><div class=""><i class=""><font color="#e32400" style="font-family: Menlo;" class="">^ error: missing implementation of a non-default requirement `==`;&nbsp;</font><font color="#e32400" style="font-family: Menlo;" class="">fix-it: insert an implementation</font></i></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class=""><font color="#b92d5d" class="">extension</font>&nbsp;</font><font color="#4f7a28" face="Menlo" class="">Something</font><font face="Menlo" class="">&nbsp;{</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span></font><font color="#b92d5d" face="Menlo" class="">static</font><span style="font-family: Menlo;" class="">&nbsp;</span><font color="#b92d5d" face="Menlo" class="">func</font><span style="font-family: Menlo;" class="">&nbsp;== (_ some:&nbsp;</span><font color="#4f7a28" face="Menlo" class="">Something</font><span style="font-family: Menlo;" class="">, _ other:&nbsp;</span><font color="#4f7a28" face="Menlo" class="">Something</font><span style="font-family: Menlo;" class="">) -&gt;&nbsp;</span><font color="#4f7a28" face="Menlo" class="">Bool</font><font face="Menlo" class="">&nbsp;{</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">                </span><b class="">[<font color="#4d22b3" class="">Your Code Here]</font></b></font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">}</font></div></div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Gor Gyolchanyan.</div></body></html>