[swift-evolution] Will Swift ever support optional methods without @objc?

Charles Constant charles at charlesism.com
Mon Nov 14 19:39:35 CST 2016


The disadvantage is that it's easy in Swift to push millions of things in
protocols, and end up with:

    class MyClass: SwiftProtocollable, MoreFunctionalityable, MoreHereable,
StillMoreable, ThisTooable, StillMoreable {
        ...
    }

Given enough thought, maybe this can be avoided, but the problem is (as far
as I can tell, and I may be out to lunch) that protocols are
philosophically the "correct" way in Swift to do a lot of things.

I recently wrote a tiny framework for Drag n Drop, and I wound up with
various combinations of almost 10 protocols - and, afai could tell, that
was "correct" because I was specifying the different abilities of my
classes (eg: do they have methods for reading text data, file data, writing
promises, reading promises, etc) It's just not easy to read.




On Mon, Nov 14, 2016 at 4:10 PM, Benjamin Spratling via swift-evolution <
swift-evolution at swift.org> wrote:

> Given optionals and closures, is it necessary to support optional
> protocols?
>
> protocol MyProtocol {
>         var titleForRow:((_ indexPath:IndexPath)->(String))? { get }
> }
>
> One disadvantage is that you need Obj-C, which means it doesn’t run on
> linux, or several other platforms.
> Another disadvantage, as I understand it, is it requires slower Obj-c
> dispatch, instead of witness tables.  Obj-C dispatch also only considers
> names, not argument & return types.
>
> > On Nov 14, 2016, at 5:48 PM, Rick Mann via swift-evolution <
> swift-evolution at swift.org> wrote:
> >
> > Will Swift ever support optional methods without @objc?
> >
> > What are the disadvantages of marking a protocol @objc?
> >
> > Thanks!
> >
> > --
> > Rick Mann
> > rmann at latencyzero.com
> >
> >
> > _______________________________________________
> > swift-evolution mailing list
> > swift-evolution at swift.org
> > https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> 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/20161114/e4172f2d/attachment.html>


More information about the swift-evolution mailing list