On Fri, May 13, 2016 at 12:55 PM, Vladimir.S <sva...@gmail.com> wrote:
> > I'm not convinced by this example. > > 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. > > In two words - he wants to achieve requirement 'return Self class or any > of base classes', as current `->Self` requires 'strictly return Self class' > 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. Going back to the example, let's say you have the requested protocol Fooable { func foo() -> StaticSelf } class A: Fooable { func foo() -> A { return A() } } class B: A { } How would you use foo() in generic code? func bar<T: Fooable>(_ x: T) -> X { return x.foo() } What does bar() return? What do you put in place of X in its declaration? 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? Nicola
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution