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 
> <[email protected]> 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 
>> <[email protected]> wrote:
>> 
>> Will Swift ever support optional methods without @objc?
>> 
>> What are the disadvantages of marking a protocol @objc?
>> 
>> Thanks!
>> 
>> -- 
>> Rick Mann
>> [email protected]
>> 
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> [email protected]
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to