[swift-evolution] [Pitch] Support for pure functions. Part n + 1.

Dennis Weissmann dennis at dennisweissmann.me
Thu Feb 16 15:32:56 CST 2017


> On Feb 16, 2017, at 10:24 PM, David Sweeris <davesweeris at mac.com> wrote:
> 
> 
>> On Feb 16, 2017, at 13:10, Dennis Weissmann via swift-evolution <swift-evolution at swift.org> 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.
> 

That makes a lot of sense and would be consistent with @escaping's behavior.

> - Dave Sweeris.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3585 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170216/0cc14faa/attachment.p7s>


More information about the swift-evolution mailing list