[swift-evolution] Should we rename "class" when referring to protocol conformance?

John McCall rjmccall at apple.com
Mon May 2 13:10:03 CDT 2016


> On May 2, 2016, at 6:55 AM, David Sweeris via swift-evolution <swift-evolution at swift.org> wrote:
> I was just thinking that:
> protocol Foo : reference {}
> might be more to the point than:
> protocol Foo : class {}
> 
> I know that it’s currently a moot point because classes are the only* reference-semantics type of type in Swift, but it’s conceivable that there might some day be others.

Functions/closures have reference semantics, but they can't conform to protocols.  Anyway, that's not the important question; the important question is why we would add a new kind of first-class reference type to the language — that can implement class protocols, no less — instead of, at most, calling it a new kind of class.

> Anyway, I’m not saying it’s a big deal or anything, I’m just trying to think of any source-breaking changes we might want to make before Swift 3 drops, and this seems like an easy one.
> 
> - Dave Sweeris
> 
> * I’m not actually sure this is true. I have a very vague recollection about some protocols getting reference semantics in certain circumstances, but the memory is so hazy I’m not sure I trust it. Also I can’t remember if the “indirect” keyword in enums affects the semantics.

Other than permitting otherwise-infinite types, no.

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160502/c64a94cc/attachment.html>


More information about the swift-evolution mailing list