<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="">Hi Dave,<div class=""><br class=""></div><div class="">I agree with 肇鑫. Your issue and his seem like two separate issues, and I’d also like to see his issue implemented. For example, imagine I wanted to define this protocol:</div><div class=""><br class=""></div><div class="">protocol&nbsp;Logger {<br class="">&nbsp; &nbsp;&nbsp;func&nbsp;print()<br class="">&nbsp; &nbsp;&nbsp;func&nbsp;print(message:&nbsp;String)</div><div class="">&nbsp; &nbsp;&nbsp;func&nbsp;print(path:&nbsp;String)</div><div class="">&nbsp; &nbsp; func&nbsp;print(line: Int)</div><div class="">&nbsp; &nbsp;&nbsp;func&nbsp;print(message: String, path:&nbsp;String)</div><div class="">&nbsp; &nbsp; func&nbsp;print(message: String, line: Int)</div><div class="">&nbsp; &nbsp; func&nbsp;print(path:&nbsp;String, line: Int)</div><div class="">&nbsp; &nbsp; func&nbsp;print(message: String, path:&nbsp;String, line: Int)</div><div class="">}</div><div class=""><br class=""></div><div class="">It would be much simpler if I could more simply write:</div><div class=""><br class=""></div><div class=""><div class="">protocol&nbsp;Logger&nbsp;{<br class=""></div><div class="">&nbsp; &nbsp; func&nbsp;print(message: String = default, path:&nbsp;String = default, line: Int = default)</div><div class="">}</div></div><div class=""><br class=""></div><div class="">Which is a separate issue then what you propose which would allow the same as the following for&nbsp;<b class="">init</b>&nbsp;as well:</div><div class=""><br class=""></div><div class=""><div class="">protocol&nbsp;Logger&nbsp;{<br class=""></div><div class="">&nbsp; &nbsp; func&nbsp;print(message: String)</div><div class="">}</div></div><div class=""><br class=""></div><div class="">class NSLogger {</div><div class="">&nbsp; &nbsp; func print(message: String, path: String, line: Int) {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; // ...</div><div class="">&nbsp; &nbsp; }</div><div class="">}</div><div class=""><br class=""></div><div class="">extension NSLogger: Logger {</div><div class="">&nbsp; &nbsp; conformance {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; print(message)</div><div class="">&nbsp; &nbsp; }</div><div class="">}</div><div class=""><br class=""></div><div style=""><blockquote type="cite" class=""><div class="">On 17 Jan 2016, at 18:09, 肇鑫 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">It is not to&nbsp;<i class="">conform to the same function name but with &nbsp;different signatures</i>. It is the protocol limits in current Swift. You can implement a protocol function with default values. But the protocol can't call the function with the default value. So you have to add another function that has no argument in the protocol and change the implementation.<br class=""></div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif">current code:</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default"><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; color: rgb(187, 44, 162);" class="">protocol<span style="" class=""> A {</span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> printSomething(something:<span style="color:rgb(112,61,170)" class="">String</span>)</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="color:rgb(187,44,162)" class="">struct</span> Foo:<span style="color:rgb(79,129,135)" class="">A</span> {</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> printSomething(something:<span style="color:rgb(112,61,170)" class="">String</span> = <span style="color:rgb(209,47,27)" class="">"some thing"</span>) {</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(61,29,129)" class="">print</span>(something)</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">&nbsp; &nbsp; }</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; color: rgb(49, 89, 93);" class=""><span style="color:rgb(79,129,135)" class="">Foo</span><span style="" class="">().</span>printSomething<span style="" class="">() </span><span style="color:rgb(0,132,0)" class="">// some thing</span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">(</span><span style="color:rgb(79,129,135)" class="">Foo</span><span style="" class="">() </span><span style="color:rgb(187,44,162)" class="">as</span><span style="" class=""> </span><span style="color:rgb(79,129,135)" class="">A</span><span style="" class="">).printSomething() </span>// Missing argument for parameter #1 in call</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; color: rgb(0, 132, 0);" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class="">default value part is widely discussed in <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160111/006798.html" class="">this thread</a>, including other&nbsp;approaches&nbsp;like protocol extension.</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class="">zhaoxin</font></div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Jan 18, 2016 at 12:52 AM, J. Cheyo Jimenez <span dir="ltr" class="">&lt;<a href="mailto:cheyo@masters3d.com" target="_blank" class="">cheyo@masters3d.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">This is very interesting. The first case seems like a bug because the compiler should not let you define&nbsp;that function().&nbsp;<div class=""><br class=""></div><div class="">Do you have any actual examples when you would need to conform to the same function name but with different signatures?&nbsp;<div class=""><div class="h5"><br class=""><div class=""><br class="">On Sunday, January 17, 2016, 肇鑫 via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_default" style="font-family:georgia,serif">This proposal is the summary of the previous protocol function default value proposal and some of my new thinkings all together.</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif">Currently the compiler doesn't stop you defining two functions like:</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default"><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="color:rgb(187,44,162)" class="">func</span> printSomething(something:<span style="color:rgb(112,61,170)" class="">String</span> = <span style="color:rgb(209,47,27)" class="">"some thing"</span>) {</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">&nbsp; &nbsp; <span style="color:rgb(61,29,129)" class="">print</span>(something)</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="color:rgb(187,44,162)" class="">func</span> printSomething() {</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="color:rgb(61,29,129)" class="">print</span><span style="" class="">(</span>"some thing!"<span style="" class="">)</span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class="">However, when you call it, an error arises.</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class=""><br class=""></font></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class="">printSomething() </span>// Ambiguous use of 'printSomething'</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family:georgia,serif" class="">You may say just remove the function that has no argument. But protocol needs it.</span><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family:georgia,serif" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">protocol<span style="" class=""> A {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> printSomething(something:<span style="color:rgb(112,61,170)" class="">String</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> printSomething()</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color:rgb(187,44,162)" class="">struct</span> Foo:<span style="color:rgb(79,129,135)" class="">A</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> printSomething(something:<span style="color:rgb(112,61,170)" class="">String</span>) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(61,29,129)" class="">print</span>(something)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> printSomething() {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:rgb(187,44,162)" class="">self</span><span style="" class="">.</span>printSomething<span style="" class="">(</span><span style="color:rgb(209,47,27)" class="">"some thing"</span><span style="" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin:0px;line-height:normal" class="">












</p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class="">If you do't define the no-argument function in protocol A. You can not use the function by (Foo() as A).printSomething().</span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class="">As we all know, a function with default values, can rewrite to two or more equivalent functions. For example,</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class=""><br class=""></font></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color:rgb(187,44,162)" class="">struct</span> Bar {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> add(int1:<span style="color:rgb(112,61,170)" class="">Int</span> = <span style="color:rgb(39,42,216)" class="">1</span>, int2:<span style="color:rgb(112,61,170)" class="">Int</span> = <span style="color:rgb(39,42,216)" class="">2</span>, int3:<span style="color:rgb(112,61,170)" class="">Int</span> = <span style="color:rgb(39,42,216)" class="">3</span>) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(61,29,129)" class="">print</span>(int1 + int2 + int3)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">



</p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class="">is equivalent to&nbsp;</span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color:rgb(187,44,162)" class="">struct</span> Bar {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> add(int1:<span style="color:rgb(112,61,170)" class="">Int</span>, int2:<span style="color:rgb(112,61,170)" class="">Int</span>, int3:<span style="color:rgb(112,61,170)" class="">Int</span>) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(61,29,129)" class="">print</span>(int1 + int2 + int3)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> add() {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">self</span>.<span style="color:rgb(49,89,93)" class="">add</span>(<span style="color:rgb(39,42,216)" class="">1</span>, int2: <span style="color:rgb(39,42,216)" class="">2</span>, int3: <span style="color:rgb(39,42,216)" class="">3</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> add(int1:<span style="color:rgb(112,61,170)" class="">Int</span>) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">self</span>.<span style="color:rgb(49,89,93)" class="">add</span>(int1, int2: <span style="color:rgb(39,42,216)" class="">2</span>, int3: <span style="color:rgb(39,42,216)" class="">3</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> add(int1:<span style="color:rgb(112,61,170)" class="">Int</span>, int2:<span style="color:rgb(112,61,170)" class="">Int</span>) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">self</span>.<span style="color:rgb(49,89,93)" class="">add</span>(int1, int2: int2, int3: <span style="color:rgb(39,42,216)" class="">3</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal" class="">















</p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class="">So my proposal is let compiler or pre-compiler to generate the code internally, without changing the original code, &nbsp;base on the functions that have default values.</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class="">Then we need not to define&nbsp;multiple functions in a protocol when we need function with default values.</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class="">new code:</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class=""><br class=""></font></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">protocol<span style="" class=""> A {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> printSomething(something:<span style="color:rgb(112,61,170)" class="">String</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color:rgb(187,44,162)" class="">struct</span> Foo:<span style="color:rgb(79,129,135)" class="">A</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> printSomething(something:<span style="color:rgb(112,61,170)" class="">String</span> = <span style="color:rgb(209,47,27)" class="">"some thing"</span>) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(61,29,129)" class="">print</span>(something)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin:0px;line-height:normal" class="">







</p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class="">If we don't want to change our previous code, we may also need to introduce another keyword defaultValue. This keyword is used only in a protocol to restrict if a function's argument can have a default value. If a function use it, but the implementation doesn't give a default value, or vice versa, an error arises.</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">new code:</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">protocol<span style="" class="">&nbsp;A {</span></div><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="">func</span>&nbsp;printSomething(something:<span style="color:rgb(112,61,170)" class="">String</span>&nbsp;= defaultValue)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color:rgb(187,44,162)" class="">struct</span>&nbsp;Foo:<span style="color:rgb(79,129,135)" class="">A</span>&nbsp;{</div><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="">func</span>&nbsp;printSomething(something:<span style="color:rgb(112,61,170)" class="">String</span>&nbsp;=&nbsp;<span style="color:rgb(209,47,27)" class="">"some thing"</span>) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color:rgb(61,29,129)" class="">print</span>(something)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp;&nbsp;}</div><p style="margin:0px;line-height:normal" class=""></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class="">This keyword is useful. With it, you can still use Swift in old way. Which means you need not to change code like below if you don't want to.</span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class="">old code:</span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">protocol<span style="" class="">&nbsp;A {</span></div><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="">func</span>&nbsp;printSomething(something:<span style="color:rgb(112,61,170)" class="">String</span>)</div><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="">func</span>&nbsp;printSomething()</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color:rgb(187,44,162)" class="">struct</span>&nbsp;Foo:<span style="color:rgb(79,129,135)" class="">A</span>&nbsp;{</div><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="">func</span>&nbsp;printSomething(something:<span style="color:rgb(112,61,170)" class="">String</span>) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color:rgb(61,29,129)" class="">print</span>(something)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><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="">func</span>&nbsp;printSomething() {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">self</span><span style="" class="">.</span>printSomething<span style="" class="">(</span><span style="color:rgb(209,47,27)" class="">"some thing"</span><span style="" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin:0px;line-height:normal" class=""></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><font face="georgia, serif" class="">But if you want to write new code. You can just write it in the new way,&nbsp;enjoining the simpler and&nbsp;clearer.</font></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class="">zhaoxin</span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-family:georgia,serif;font-size:small" class=""><br class=""></span></div></div></div>
</blockquote></div></div></div></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>