<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="">Instead of adding stuff to the protocol declaration, can we add it to the object definition?</div><div class=""><br class=""></div><div class="">Right now, IMHO, there’s a bug in the way protocols and functions w/ default parameters interact (or rather, don’t)…</div><div class=""><br class=""></div><div class="">Say I have this protocol (which, BTW, I end up adding to a lot of my projects for providing default values):</div><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;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">protocol</span> Initable {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">init</span>()</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// Along with most other builtin types I use</div></div><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="">Initable</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; color: rgb(0, 132, 0);" class=""><br class=""></div></div></blockquote><div class="">and this class:</div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">class</span> Variable &lt;T: Initable&gt; {</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> value: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span></div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> name: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span></div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">init</span>(path: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">__FILE__</span>, line: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">__LINE__</span>) {</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">value</span> = T()</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">name</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">getDeclNameFromSource</span>(path: path, line: line)</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">init</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">_</span> value: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>, path: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">__FILE__</span>, line: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">__LINE__</span>) {</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">value</span> = value</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">name</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">getDeclNameFromSource</span>(path: path, line: line)</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">init</span>(name: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span>, value: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>) {</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">value</span> = value</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">name</span> = name</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; line-height: normal;" class="">}</div><div class=""><br class=""></div></div></blockquote><div class="">Now, `Initable` says* that</div><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(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> x = </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">() </span>// where T: Initable, of course</div></div><div class=""><br class=""></div></blockquote><div class="">&nbsp;is valid code. Do you know what else is valid?</div><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(0, 132, 0);" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> x = </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Variable</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&lt;</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="">&gt;() </span>// Hooray! Default values!</div><div class=""><br class=""></div></div></div></blockquote><div class="">Yet, despite the fact that, from the API user’s point of view, `Variable` already has everything it needs to conform to `Initable`, you can’t write “extension Variable : Initable” without either getting a non-conformance error or, if you then add init() { fatalError() }, getting an “ambiguous expression” error wherever you actually try to call Variable(). 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&nbsp;<span style="color: rgb(187, 44, 162);" class="">__LINE__</span>&nbsp;or&nbsp;something as your default parameter, but&nbsp;it’s still annoying (to me, anyway).</div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><br class=""></span></font></div><div class="">I think we might be able to kill two birds with one stone here… What if protocol conformance had to be declared <i class="">and</i>&nbsp;it was done implicitly for anything for which there was already a perfect match?</div><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="">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="">Initable</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; &nbsp;&nbsp;</span></font><span style="font-family: Menlo; font-size: 11px; color: rgb(0, 132, 0);" class="">// Implicitly generated because Int.init() (</span><font color="#008400" face="Menlo" class=""><span style="font-size: 11px;" class="">with no default parameters)&nbsp;already&nbsp;exists</span></font></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">&nbsp; &nbsp;&nbsp;</span><font color="#bb2ca2" face="Menlo" class=""><span style="font-size: 11px;" class="">conformance</span></font><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp;</span></font><font face="Menlo" class=""><span style="font-size: 11px;" class="">{</span></font></div><div style="margin: 0px; line-height: normal;" class=""><font color="#008400" face="Menlo" style="font-family: Menlo; font-size: 11px;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>//(protocol_identifier).(requirement_indentifer) = (</font><font color="#008400" face="Menlo" class=""><span style="font-size: 11px;" class="">expression)</span></font></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color: rgb(79, 129, 135);" class="">Initable</span>.<span style="color: rgb(187, 44, 162);" class="">init</span>() =&nbsp;<span style="color: rgb(187, 44, 162);" class="">init</span>() <span style="color: rgb(0, 132, 0);" class="">// or really any expression that evaluates to an Int</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-family: Menlo; font-size: 11px;" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div></blockquote><div class=""><br class=""></div><div class="">Then we could get both your default parameter support (I think)&nbsp;<i class="">and</i>&nbsp;fix this “bug of non-intuitivity” (which people keep telling me isn’t really a bug because of what protocols <i class="">actually</i>&nbsp;mean*) simply by being able to explicitly write it out:</div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162);" class="">class</span>&nbsp;Variable &lt;T: Initable&gt; :&nbsp;<span style="color: rgb(79, 129, 135);" class="">Initable&nbsp;</span>{</div></div><span style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px;" class="">&nbsp; &nbsp; // Must be explicitly written, since in this case there</span><font color="#008400" face="Menlo" class=""><span style="font-size: 11px;" class="">’s no literal match</span></font><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp;&nbsp;<span style="color: rgb(187, 44, 162);" class="">conformance</span>&nbsp;{</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color: rgb(79, 129, 135);" class="">Initable.</span><span style="color: rgb(187, 44, 162);" class="">init</span>() =&nbsp;<span style="color: rgb(187, 44, 162);" class="">init</span>(<span style="color: rgb(187, 44, 162);" class="">_</span>&nbsp;value:&nbsp;<span style="color: rgb(112, 61, 170);" class="">T</span>, path:&nbsp;<span style="color: rgb(112, 61, 170);" class="">String</span>&nbsp;=&nbsp;<span style="color: rgb(187, 44, 162);" class="">__FILE__</span>, line:&nbsp;<span style="color: rgb(112, 61, 170);" class="">Int</span>&nbsp;=&nbsp;<span style="color: rgb(187, 44, 162);" class="">__LINE__</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp;&nbsp;}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; …</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">}</div></div></blockquote><div class=""><br class=""></div><div class="">In theory, we could also use this for optimizations:</div><div class=""><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class=""><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><font color="#bb2ca2" class="">private let </font>_default_int_:&nbsp;<span style="color: rgb(112, 61, 170);" class="">Int&nbsp;</span>=<font color="#bb2ca2" class=""> </font><span style="color: rgb(39, 42, 216);" class="">0</span></div></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">extension<span style="color: rgb(0, 0, 0);" class="">&nbsp;</span><span style="color: rgb(112, 61, 170);" class="">Int</span><span style="color: rgb(0, 0, 0);" class="">&nbsp;:&nbsp;</span><span style="color: rgb(79, 129, 135);" class="">Initable</span><span style="color: rgb(0, 0, 0);" class="">&nbsp;{</span></div></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">&nbsp; &nbsp;&nbsp;</span><font color="#bb2ca2" face="Menlo" class=""><span style="font-size: 11px;" class="">conformance</span></font><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp;</span></font><font face="Menlo" class=""><span style="font-size: 11px;" class="">{</span></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></font><span style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);" class="">Initable</span><font face="Menlo" class=""><span style="font-size: 11px;" class="">.</span></font><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">init</span><font face="Menlo" class=""><span style="font-size: 11px;" class="">() =&nbsp;</span></font><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 11px;" class="">_default_int_</span><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp;</span></font><span style="font-family: Menlo; font-size: 11px; color: rgb(0, 132, 0);" class="">//why bother with a function call when you could substitute a constant?</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp; &nbsp;</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;</span><span style="font-family: Menlo; font-size: 11px;" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><br class=""></div></blockquote></div><div class=""><br class=""></div><div class="">I don’t know how deep into the compiler this “conformance” clause would have to be carried… The generic specializer would certainly need it, but I don’t know enough about how that works to say how much this would actually change anything…</div><div class=""><div class=""><br class="webkit-block-placeholder"></div><div class="">- Dave Sweeris</div></div><div class=""><br class=""></div><div class="">* Yes, I know that protocol conformance is about the <i class="">actual</i> function signatures and not just what the compiler can deduce… My point is that, IMHO, it’s counter-intuitive to be able to get the same “user-level” signature, but not be able to semantically express that to the compiler.</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Jan 16, 2016, at 03:35, Goffredo Marocchi 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="">I still think that, except in certain very generic cases, default methods are something I would be wary of being easily abused.</div><div class=""><br class=""></div><div class="">Protocols, Java style interfaces, they allow users to focus only on a generic behaviour/contract without having to rely or being able to rely and/or make bonding assumptions on any implementation details of the type conforming to the protocol. Default methods in a protocol still seem to go in the opposite direction although they do offer a lot of convenience and open up new styles.<br class=""><br class="">Sent from my iPhone</div><div class=""><br class="">On 16 Jan 2016, at 11:04, Haravikk 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=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div class="">I think that the point of allowing defaults in protocols is so that you can assume a default for all types conforming to that protocol. To use your example, if you receive an instance of Name, you can only call printSomething() without arguments if you test that it is an instance of type Name. If instead you test its conformance to the Good protocol (which you might do if there are a lot of different types conforming to Good) then you have to provide a value, because you can’t infer that every possible implementation will have a default.</div><div class=""><br class=""></div><div class="">Regarding this proposal however I think it might be useful to have a distinction between a protocol function that specifies a default value for all implementations (that they must all conform to) versus one that specifies that implementations must have a default value, but not what that value must be.</div><div class=""><br class=""></div><div class="">For example, to have a fixed and altered default we currently we have to do things like this:</div><div class=""><br class=""></div><div class=""><div class="">protocol Protocol {</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>func functionWithSpecificDefault(argument:String)</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>func functionWithAnyDefault(argument:String)</div><div class="">}</div></div><div class=""><br class=""></div><div class="">extension Protocol {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>func functionWithSpecificDefault() { self.functionWithSpecificDefault(“Foo”) }</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>func functionWithAnyDefault() { self.functionWithAnyDefault(“Foo”) }</div><div class="">}</div><div class=""><br class=""></div><div class="">class MyClass : Protocol {</div><span class="Apple-tab-span" style="white-space: pre;">        </span>func functionWithSpecificDefault(argument:String) { /* Implementation here */ }<div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>func functionWithAnyDefault(argument:String) { /* Implementation here */ }</div><div class=""><br class=""><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>func functionWithAnyDefault() { self.functionWithAnyDefault(“Bar”) } // Override default</div><div class="">}</div><div class=""><br class=""></div><div class="">Which could be replaced by:</div><div class=""><br class=""></div><div class="">protocol Protocol {</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>func functionWithSpecificDefault(argument:String = “Foo")</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>func functionWithAnyDefault(argument:String = default)</div><div class="">}</div><div class=""><br class=""></div><div class="">class MyClass : Protocol {</div><span class="Apple-tab-span" style="white-space: pre;">        </span>func functionWithSpecificDefault(argument:String = “Foo") { /* Implementation here */ }<div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>func functionWithAnyDefault(argument:String = “Bar") { /* Implementation here */ }</div><div class="">}</div><div class=""><br class=""></div><div class="">However, this has the added advantage that implementing functionWithSpecificDefault with a default other than “Foo” would cause a compiler error, while doing so for functionWithAnyDefault would not (but specifying no default at all would, as one is required).</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 16 Jan 2016, at 10:15, 肇鑫 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=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:georgia,serif">No. Although you protocol's function doesn't has a default parameter value. Your implementation does. So you don't need to define another func function() in your protocol.</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default"><div class="gmail_default"><font face="georgia, serif" class="">protocol Good {</font></div><div class="gmail_default"><font face="georgia, serif" class="">&nbsp; &nbsp; func printSomething(something:String)</font></div><div class="gmail_default"><font face="georgia, serif" class="">}</font></div><div class="gmail_default"><font face="georgia, serif" class=""><br class=""></font></div><div class="gmail_default"><font face="georgia, serif" class="">struct Name:Good {</font></div><div class="gmail_default"><font face="georgia, serif" class="">&nbsp; &nbsp; func printSomething(something: String = "John") {</font></div><div class="gmail_default"><font face="georgia, serif" class="">&nbsp; &nbsp; &nbsp; &nbsp; print(something)</font></div><div class="gmail_default"><font face="georgia, serif" class="">&nbsp; &nbsp; }</font></div><div class="gmail_default"><font face="georgia, serif" class="">}</font></div><div class="gmail_default"><font face="georgia, serif" class=""><br class=""></font></div><div class="gmail_default"><font face="georgia, serif" class="">Name().printSomething()</font></div><div class="gmail_default"><font face="georgia, serif" class=""><br class=""></font></div><div class="gmail_default"><font face="georgia, serif" class="">above code works.</font></div><div class="gmail_default"><font face="georgia, serif" class=""><br class=""></font></div><div class="gmail_default"><font face="georgia, serif" class="">zhaoxin</font></div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Jan 16, 2016 at 6:05 PM, Vatsal Manot <span dir="ltr" class="">&lt;<a href="mailto:vatsal.manot@yahoo.com" target="_blank" class="">vatsal.manot@yahoo.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">It serves as a better (if not simpler) substitute for the following pattern:</div><div class="">&nbsp;</div><span class="">protocol&nbsp;Protocol<br class=""></span><span class="">{<br class=""></span><span class="">&nbsp; &nbsp;&nbsp;typealias&nbsp;Argument<br class=""></span><span class="">&nbsp; &nbsp;&nbsp;<br class=""></span><span class="">&nbsp; &nbsp;&nbsp;func&nbsp;function()<br class=""></span><span class="">&nbsp; &nbsp;&nbsp;func&nbsp;function(_:&nbsp;Argument)<br class=""></span><div class=""><div class="h5"><span class="">}<br class=""></span><span class="">&nbsp;<br class=""></span><div class=""><div class=""><blockquote type="cite" class=""><div class="">On 16-Jan-2016, at 3:29 PM, 肇鑫 &lt;<a href="mailto:owenzx@gmail.com" target="_blank" class="">owenzx@gmail.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:georgia,serif">I wonder where is the good for a protocol designer on this?<br class=""></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 class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Jan 16, 2016 at 5:23 PM, Vatsal Manot via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Currently, the following the code fails with multiple errors:<br class="">
<br class="">
protocol Protocol<br class="">
{<br class="">
&nbsp; &nbsp; typealias Argument<br class="">
<br class="">
&nbsp; &nbsp; func function(argument: Argument = default)<br class="">
}<br class="">
<br class="">
I propose that we allow protocols to require functions with default parameter values. I can’t see any disadvantages to this, and the change would only be additive.<br class="">
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class=""><div dir="ltr" class=""><div class=""><br class="">Owen Zhao<br class=""></div></div></div>
</div></div>
</div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><br class="">Owen Zhao<br class=""></div></div></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></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></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=""></div></body></html>