[swift-evolution] Should we rename "class" when referring to protocol conformance?
Basem Emara
contact at basememara.com
Thu May 5 10:01:48 CDT 2016
How about mutating keyword just like func's:
mutating protocol Foo {…}
Isn’t that what the current “class” keyword is trying to indicate? It feels awkward that a protocol would inherit from a reference type when just looking at the syntax, whether it be class, AnyObject, etc.
> On May 5, 2016, at 10:52 AM, Jesse Squires via swift-evolution <swift-evolution at swift.org> wrote:
>
> > Personally I have always felt “class” was an oddball special case here
> that's unneeded because we have a perfectly good protocol that means the
> same thing: AnyObject.
>
> +1
>
> Repurposing the `class` keyword to constrain a protocol to reference types has always felt awkward, out-of-place, and inconsistent with the rest of the language. I would love to see this changed to `AnyObject` as Dave suggests.
>
> Given all of the other great refinements for language consistency that have been proposed and accepted for Swift 3, the awkwardness of using `class` here is even greater than before.
>
> Jesse
>
>
>
> On Tue, May 3, 2016 at 11:06 AM, Dave Abrahams via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>
> on Mon May 02 2016, David Sweeris <swift-evolution at swift.org <mailto: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. 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.
>
> Personally I have always felt “class” was an oddball special case here
> that's unneeded because we have a perfectly good protocol that means the
> same thing: AnyObject.
>
> --
> Dave
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>
>
>
> --
> Jesse Squires
>
> blog | jessesquires.com <http://www.jessesquires.com/>
> github | github.com/jessesquires <http://www.github.com/jessesquires>
> hexedbits | hexedbits.com <http://www.hexedbits.com/>_______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160505/ef6688db/attachment.html>
More information about the swift-evolution
mailing list