<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 13, 2016 at 12:55 PM, Vladimir.S <span dir="ltr"><<a href="mailto:svabox@gmail.com" target="_blank">svabox@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> I'm not convinced by this example.<br>
<br>
Probably my & Matthew's previous discussion in `[swift-evolution] [RFC] #Self` topic will help you. I was trying there to find out (in primitive examples) what Matthew is trying to achive with this `->StaticSelf` in protocol.<br>
<br>
In two words - he wants to achieve requirement 'return Self class or any of base classes', as current `->Self` requires 'strictly return Self class'<br></blockquote><div><br></div><div>I think I understand what the request is, but I'm not sure if it's a problem worth solving, and if this would be the right solution.<br></div><div> <br></div><div>Going back to the example, let's say you have the requested<br><br>protocol Fooable {<br>
func foo() -> StaticSelf<br>
}<br><br>class A: Fooable {<br> func foo() -> A { return A() }<br>
}<br></div><div><br></div><div>class B: A {<br>}<br><br></div><div>How would you use foo() in generic code?<br><br></div><div>func bar<T: Fooable>(_ x: T) -> X {<br></div><div> return x.foo()<br>}<br><br></div><div>What does bar() return? What do you put in place of X in its declaration?<br></div><div>You can't use T, you can't use T.StaticSelf. So what's the purpose of having a protocol if you can't use it in generic code?<br><br></div><br></div><div class="gmail_quote">Nicola<br><br></div></div></div>