<div dir="ltr"><div>Similar has been discussed in the topic: "two protocols with the same method name", it starts here:<div> <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160104/005673.html" target="_blank">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160104/005673.html</a></div></div><div><br></div><div>Here's another solution you may not have considered:</div><div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">struct</span> Foo:<span style="color:rgb(79,129,135)">A</span> {</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> printSomething(something:<span style="color:rgb(112,61,170)">String</span> = <span style="color:rgb(209,47,27)">"some thing"</span>) {</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(61,29,129)">print</span>(something)</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> }</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="color:rgb(187,44,162)"><br></span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="color:rgb(187,44,162)"> @implements</span>(A.printSomething)<br></p><p style="margin:0px;line-height:normal"><font face="Menlo"><span style="font-size:11px"> </span></font><font color="#bb2ca2" face="Menlo"><span style="font-size:11px">private func</span></font><font face="Menlo"><span style="font-size:11px"> _printSomething() { </span></font><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">self</span><span style="font-family:Menlo;font-size:11px;color:rgb(0,0,0)">.</span><span style="color:rgb(49,89,93);font-family:Menlo;font-size:11px">printSomething</span><span style="font-family:Menlo;font-size:11px;color:rgb(0,0,0)">(</span><span style="font-family:Menlo;font-size:11px;color:rgb(0,0,0)">) </span><span style="font-family:Menlo;font-size:11px">}</span></p><p style="font-size:13px;margin:0px;line-height:normal"></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></p><div><div>This was derived from the message by Joe Groff, in the linked thread:</div><div><br></div><div><div>> Swift's protocol conformance model doesn't rely on the name of the member matching the name of the requirement it satisfies. One possibility here is to introduce an attribute to explicitly declare what protocol requirement(s) a member is intended to satisfy:</div><div>> </div><div>> class X: A, B {</div><div>> @implements(A.ring)</div><div>> var weddingRing: String</div><div>> </div><div>> @implements(B.ring)</div><div>> var ringtone: String</div><div>> }</div><div>> </div></div></div><div><br></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 18, 2016 at 5:19 AM, David Hart via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Dave,<div><br></div><div>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><br></div><div>protocol Logger {<br> func print()<br> func print(message: String)</div><div> func print(path: String)</div><div> func print(line: Int)</div><div> func print(message: String, path: String)</div><div> func print(message: String, line: Int)</div><div> func print(path: String, line: Int)</div><div> func print(message: String, path: String, line: Int)</div><div>}</div><div><br></div><div>It would be much simpler if I could more simply write:</div><div><br></div><div><div>protocol Logger {<br></div><div> func print(message: String = default, path: String = default, line: Int = default)</div><div>}</div></div><div><br></div><div>Which is a separate issue then what you propose which would allow the same as the following for <b>init</b> as well:</div><div><br></div><div><div>protocol Logger {<br></div><div> func print(message: String)</div><div>}</div></div><div><br></div><div>class NSLogger {</div><div> func print(message: String, path: String, line: Int) {</div><div> // ...</div><div> }</div><div>}</div><div><br></div><div>extension NSLogger: Logger {</div><div> conformance {</div><div> print(message)</div><div> }</div><div>}</div><div><br></div><div><blockquote type="cite"><div><div class="h5"><div>On 17 Jan 2016, at 18:09, 肇鑫 via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br></div></div><div><div><div class="h5"><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">It is not to <i>conform to the same function name but with 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></div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">current code:</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default"><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(187,44,162)">protocol<span> A {</span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"> <span style="color:rgb(187,44,162)">func</span> printSomething(something:<span style="color:rgb(112,61,170)">String</span>)</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><br></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="color:rgb(187,44,162)">struct</span> Foo:<span style="color:rgb(79,129,135)">A</span> {</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"> <span style="color:rgb(187,44,162)">func</span> printSomething(something:<span style="color:rgb(112,61,170)">String</span> = <span style="color:rgb(209,47,27)">"some thing"</span>) {</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"> <span style="color:rgb(61,29,129)">print</span>(something)</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"> }</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><br></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(49,89,93)"><span style="color:rgb(79,129,135)">Foo</span><span>().</span>printSomething<span>() </span><span style="color:rgb(0,132,0)">// some thing</span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,132,0)"><span>(</span><span style="color:rgb(79,129,135)">Foo</span><span>() </span><span style="color:rgb(187,44,162)">as</span><span> </span><span style="color:rgb(79,129,135)">A</span><span>).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)"><br></div><div style="margin:0px;line-height:normal"><font face="georgia, serif">default value part is widely discussed in <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160111/006798.html" target="_blank">this thread</a>, including other approaches like protocol extension.</font></div><div style="margin:0px;line-height:normal"><font face="georgia, serif"><br></font></div><div style="margin:0px;line-height:normal"><font face="georgia, serif">zhaoxin</font></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 18, 2016 at 12:52 AM, J. Cheyo Jimenez <span dir="ltr"><<a href="mailto:cheyo@masters3d.com" target="_blank">cheyo@masters3d.com</a>></span> wrote:<br><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 that function(). <div><br></div><div>Do you have any actual examples when you would need to conform to the same function name but with different signatures? <div><div><br><div><br>On Sunday, January 17, 2016, 肇鑫 via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><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></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></div><div class="gmail_default"><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="color:rgb(187,44,162)">func</span> printSomething(something:<span style="color:rgb(112,61,170)">String</span> = <span style="color:rgb(209,47,27)">"some thing"</span>) {</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"> <span style="color:rgb(61,29,129)">print</span>(something)</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><br></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="color:rgb(187,44,162)">func</span> printSomething() {</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(209,47,27)"><span> </span><span style="color:rgb(61,29,129)">print</span><span>(</span>"some thing!"<span>)</span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><font face="georgia, serif">However, when you call it, an error arises.</font></div><div style="margin:0px;line-height:normal"><font face="georgia, serif"><br></font></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span>printSomething() </span>// Ambiguous use of 'printSomething'</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><span style="font-family:georgia,serif">You may say just remove the function that has no argument. But protocol needs it.</span><br></div><div style="margin:0px;line-height:normal"><span style="font-family:georgia,serif"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)">protocol<span> A {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> printSomething(something:<span style="color:rgb(112,61,170)">String</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> printSomething()</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">struct</span> Foo:<span style="color:rgb(79,129,135)">A</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> printSomething(something:<span style="color:rgb(112,61,170)">String</span>) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(61,29,129)">print</span>(something)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"> <br></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> printSomething() {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(49,89,93)"><span> </span><span style="color:rgb(187,44,162)">self</span><span>.</span>printSomething<span>(</span><span style="color:rgb(209,47,27)">"some thing"</span><span>)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> }</div><p style="margin:0px;line-height:normal">
</p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small">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"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="margin:0px;line-height:normal"><font face="georgia, serif">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"><font face="georgia, serif"><br></font></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">struct</span> Bar {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> add(int1:<span style="color:rgb(112,61,170)">Int</span> = <span style="color:rgb(39,42,216)">1</span>, int2:<span style="color:rgb(112,61,170)">Int</span> = <span style="color:rgb(39,42,216)">2</span>, int3:<span style="color:rgb(112,61,170)">Int</span> = <span style="color:rgb(39,42,216)">3</span>) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(61,29,129)">print</span>(int1 + int2 + int3)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">
</p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small">is equivalent to </span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">struct</span> Bar {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> add(int1:<span style="color:rgb(112,61,170)">Int</span>, int2:<span style="color:rgb(112,61,170)">Int</span>, int3:<span style="color:rgb(112,61,170)">Int</span>) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(61,29,129)">print</span>(int1 + int2 + int3)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"> <br></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> add() {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">self</span>.<span style="color:rgb(49,89,93)">add</span>(<span style="color:rgb(39,42,216)">1</span>, int2: <span style="color:rgb(39,42,216)">2</span>, int3: <span style="color:rgb(39,42,216)">3</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"> <br></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> add(int1:<span style="color:rgb(112,61,170)">Int</span>) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">self</span>.<span style="color:rgb(49,89,93)">add</span>(int1, int2: <span style="color:rgb(39,42,216)">2</span>, int3: <span style="color:rgb(39,42,216)">3</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"> <br></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> add(int1:<span style="color:rgb(112,61,170)">Int</span>, int2:<span style="color:rgb(112,61,170)">Int</span>) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">self</span>.<span style="color:rgb(49,89,93)">add</span>(int1, int2: int2, int3: <span style="color:rgb(39,42,216)">3</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> }</div><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal">
</p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="margin:0px;line-height:normal"><font face="georgia, serif">So my proposal is let compiler or pre-compiler to generate the code internally, without changing the original code, base on the functions that have default values.</font></div><div style="margin:0px;line-height:normal"><font face="georgia, serif"><br></font></div><div style="margin:0px;line-height:normal"><font face="georgia, serif">Then we need not to define multiple functions in a protocol when we need function with default values.</font></div><div style="margin:0px;line-height:normal"><font face="georgia, serif"><br></font></div><div style="margin:0px;line-height:normal"><font face="georgia, serif">new code:</font></div><div style="margin:0px;line-height:normal"><font face="georgia, serif"><br></font></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)">protocol<span> A {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> printSomething(something:<span style="color:rgb(112,61,170)">String</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">struct</span> Foo:<span style="color:rgb(79,129,135)">A</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> printSomething(something:<span style="color:rgb(112,61,170)">String</span> = <span style="color:rgb(209,47,27)">"some thing"</span>) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(61,29,129)">print</span>(something)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> }</div><p style="margin:0px;line-height:normal">
</p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div><div style="margin:0px;line-height:normal"><font face="georgia, serif"><br></font></div><div style="margin:0px;line-height:normal"><font face="georgia, serif"><br></font></div><div style="margin:0px;line-height:normal">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"><br></div><div style="margin:0px;line-height:normal">new code:</div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)">protocol<span> A {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> printSomething(something:<span style="color:rgb(112,61,170)">String</span> = defaultValue)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">struct</span> Foo:<span style="color:rgb(79,129,135)">A</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> printSomething(something:<span style="color:rgb(112,61,170)">String</span> = <span style="color:rgb(209,47,27)">"some thing"</span>) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(61,29,129)">print</span>(something)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> }</div><p style="margin:0px;line-height:normal"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small">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"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small">old code:</span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)">protocol<span> A {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> printSomething(something:<span style="color:rgb(112,61,170)">String</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> printSomething()</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">struct</span> Foo:<span style="color:rgb(79,129,135)">A</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> printSomething(something:<span style="color:rgb(112,61,170)">String</span>) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(61,29,129)">print</span>(something)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"> <br></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">func</span> printSomething() {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(49,89,93)"><span> </span><span style="color:rgb(187,44,162)">self</span><span>.</span>printSomething<span>(</span><span style="color:rgb(209,47,27)">"some thing"</span><span>)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> }</div><p style="margin:0px;line-height:normal"></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="margin:0px;line-height:normal"><font face="georgia, serif">But if you want to write new code. You can just write it in the new way, enjoining the simpler and clearer.</font></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small">zhaoxin</span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div><div style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-family:georgia,serif;font-size:small"><br></span></div></div></div>
</blockquote></div></div></div></div>
</blockquote></div><br></div></div></div><span class="">
_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></span></div></blockquote></div><br></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>