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

Rick Mann rmann at latencyzero.com
Mon Nov 14 19:50:31 CST 2016


> On Nov 14, 2016, at 16:10 , 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 }
> }

Well, it would be nice if making a func optional at least acted as syntactic sugar for this, wouldn't it?

> 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.

Does implementing an @objc protocol then make all my class' methods use objc-dispatch? Or just the ones in the protocol?

Thanks,

> 
>> 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


-- 
Rick Mann
rmann at latencyzero.com




More information about the swift-evolution mailing list