> On Feb 16, 2017, at 13:10, Dennis Weissmann via swift-evolution 
> <[email protected]> wrote:
> 
> Secondly, are they inherited? So if ClassA has a pure function a(), can I 
> override it in subclass ClassB: ClassA to be impure? (I think no)

I would agree. IIUC, the "pureness" of A's implementation of a() becomes a moot 
point if B's implementation doesn't have to have at least as strong of a 
constraint,  because otherwise all the optimizations that the compiler makes 
would break as soon as someone passes a B in instead of an A.

> Can I annotate a function in a protocol to force it to be pure? (not sure 
> about this one)

I would say yes, for similar reasons: if the attribute doesn't hold for *all* 
implementations, the compiler can't assume it holds for any. At least not with 
the way generics work now, IIUC.

- Dave Sweeris.
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to