[swift-evolution] [Proposal draft] Referencing the Objective-C selector of a method

Douglas Gregor dgregor at apple.com
Tue Jan 12 11:32:16 CST 2016

> On Jan 11, 2016, at 11:42 PM, Brent Royal-Gordon <brent at architechies.com> wrote:
>> control.sendAction(Selector(MyApplication.doSomething), to: target, forEvent: event)
> How bad an idea would it be to make it simply be:
> 	control.sendAction(MyApplication.doSomething, to: target, forEvent: event)
> That is, implicitly convert eligible unbound method references to selectors? From what I can tell, there's already going to be a certain amount of magic involved in this Selector initializer.

I’m strongly against making this an implicit conversion. It’s a very lossy conversion, losing bother type information and (for something like myApplicationInstance.doSomething) the apparently-bound “self”. It should also not be super-common (so we don’t need to syntax-optimize it) and isn’t available where there is no Objective-C runtime.

	- Doug

More information about the swift-evolution mailing list