<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=""><div class="">I failed to mention that It is currently possible to create a protocol extension with a default argument, but this is not ideal. This has made the topic complex enough to warrant a new thread and I will not hijack this thread any longer. If anyone is interested, I will start a new thread for this proposal.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><span style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 13px;" class="">// Currently works&nbsp;</span></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">protocol</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> P {</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> ff( a:</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class=""> )</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">P</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> ff( a:</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">=</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span><span style="font-variant-ligatures: no-common-ligatures" class=""> ) {</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">( </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"extension method"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> ) &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// I believe that this should be in the protocol</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">fatalError</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">( </span><span style="font-variant-ligatures: no-common-ligatures" class="">"There is not sensible default implementation. This method exists to make the compiler happy"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> )</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">struct</span><span style="font-variant-ligatures: no-common-ligatures" class=""> S : </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">P</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> ff( a:</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="">) { &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// Does not override the extension method. Will not be called unless `a` is passed.&nbsp;</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> p:</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">P</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">S</span><span style="font-variant-ligatures: no-common-ligatures" class="">()</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">p</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">ff</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">()&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// Will crash. Calls the extension method, which is never "overridden"</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 26, 2017, at 3:09 PM, Christopher Kornher via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">A comment: Your description of #2 is a little confusing. Functions with default arguments can currently satisfy protocols. Perhaps it should be “Allow functions with <b class="">extra</b> default arguments to satisfy protocols"</div><div class=""><br class=""></div><div class="">I have not had the need for the features you mentioned, but it would be nice to allow them both. Having closures satisfy protocol requirements would improve support for composition.</div><div class=""><br class=""></div><div class="">I would like to add one: Allow protocols to define default arguments. Implementations can define default arguments in protocol implementations but that is not particularly useful for protocol oriented programming. Perhaps I should start a different thread, but these are related. Can we call it</div><div class=""><br class=""></div><div class="">3) Allow protocols to define default parameters</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal; color: rgb(186, 45, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">protocol</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> P {</span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> f( a:</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class=""> )</span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> ff( a:Int=</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> )&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// Error: "Default argument not permitted..."</span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal; min-height: 15px;" class=""><br class=""></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">struct</span><span style="font-variant-ligatures: no-common-ligatures" class=""> S : </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">P</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> f( a:</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures;" class="">=</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> ) { &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// Currently legal, but not useful for protocol oriented programming</span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><p style="margin: 0px; line-height: normal; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></p></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> ff( a:</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures;" class="">=</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">3</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> ) { &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// A little confusing to the uninitiated perhaps, but useful</span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// and consistent with method overrides.</span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal; min-height: 15px;" class=""><br class=""></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> p:</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">P</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = S()</span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal; min-height: 15px;" class=""><br class=""></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">p.f() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// Fails (as it should since the protocol does not have a default value)</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">p.ff()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// Would succeed if the protocol could have a default param.</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //&nbsp;I find myself wanting this behavior frequently</div></div></div></blockquote><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="margin: 0px; line-height: normal; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span></div></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><span style="font-variant-ligatures: no-common-ligatures" class=""></span></div></div><div class=""><blockquote type="cite" class=""><div class="">On Mar 26, 2017, at 1:04 PM, David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""><br class=""></div><div class="">On Mar 26, 2017, at 11:12, Karl Wagner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class="">I’d like to pitch the following two language changes. Both of them are technically possible today if you manually write thunks for the relevant protocol requirements, but it would be nice if we allowed them to be written directly:<div class=""><br class=""></div><div class="">1) Allow closures to satisfy function requirements in protocols</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; color: rgb(36, 41, 46);" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">protocol</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">MyProtocol</span> {
    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">run</span>(<span class="pl-smi" style="box-sizing: border-box; color: rgb(51, 51, 51);">param</span>: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">String</span>
}

<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">struct</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">MyStruct</span> : <span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);">MyProtocol </span>{
    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> run <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> (<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>)<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">String</span>   <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">//</span> Satisfies requirement MyProtocol.run</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span>}</pre><div class=""><br class=""></div></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="">Among other things, it would make writing type-erased wrappers in the style of AnyCollection much easier. The only obvious niggle is that the argument label wouldn’t be required when invoking the closure directly. The labels have no type-system significance, but it does make it subtly easier to write less generic code than you intend do. We could solve this by having code-completion favour protocol methods in this situation, or simply to require the label when invoking a closure which implements a known protocol requirement.</blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><br class=""></div></blockquote>2) Allow functions with default parameters to satisfy function requirements in protocols<div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; color: rgb(36, 41, 46);" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">protocol</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">Sportsplayer</span> {
    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">goalsScored</span>() <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>
}

<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">struct</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">SoccerPlayer</span>: <span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);">Sportsplayer </span>{
    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">struct</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">GoalType</span> : <span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);">RawOptionSet </span>{
        <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">static</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> Shot   <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">GoalType</span>(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0x1</span>)
        <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">static</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> Volley <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">GoalType</span>(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0x10</span>)
        <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">static</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> Header <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">GoalType</span>(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0x100</span>)
        <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">static</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Any</span>    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">GoalType</span>(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0x111</span>)
    }

    <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">//</span> Default value .Any means this conforms to Sportsplayer</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span>    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">goalsScored</span>(<span class="pl-smi" style="box-sizing: border-box; color: rgb(51, 51, 51);"><span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">type</span></span>: GoalType <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> .<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Any</span>) {
      <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">//</span>...</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span>    }
}

<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">struct</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">Footballer</span>: <span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);">Sportsplayer </span>{
    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">struct</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">GoalType</span> : <span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);">RawOptionSet </span>{
        <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">static</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> Touchdown <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">GoalType</span>(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0x1</span>)
        <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">static</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> FieldGoal <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">GoalType</span>(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0x10</span>)
        <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">static</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Any</span>       <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">GoalType</span>(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0x11</span>)
    }

    <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">//</span> Default value .Any means this conforms to Sportsplayer</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span>    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">goalsScored</span>(<span class="pl-smi" style="box-sizing: border-box; color: rgb(51, 51, 51);"><span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">type</span></span>: GoalType <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> .<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Any</span>) {
      <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">//</span>...</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span>    }
}</pre><div class=""><br class=""></div></div><div class="">I often find that I want to add some optional, implementation-specific parameter to a function which implements a protocol requirement. That’s currently not possible, and it’s a bit annoying.</div></blockquote></blockquote><br class=""><div class="">IIRC, the issue with #2 is that protocols specify declaration-site details, but default parameters are implemented at the call-site. At least I believe that statement was accurate about a year(ish) ago... Dunno if anything has changed since then.</div><div class=""><br class=""></div><div class="">If it can be made to work, though, I'd be in favor of it, and I think #1 as well.</div><div class=""><br class=""></div><div class="">- Dave Sweeris</div></div>_______________________________________________<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><br class=""></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>