[swift-evolution] Will Swift ever support optional methods without @objc?
Charlie Monroe
charlie at charliemonroe.net
Tue Nov 15 00:51:22 CST 2016
One major example is the NS/UITableViewDataSource or Delegate - there are many many methods that you don't need to implement, hence are optional.
But I think that this was partially solved by default implementation of protocol methods, which pretty much does what you want...
> On Nov 15, 2016, at 1:10 AM, 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
More information about the swift-evolution
mailing list