[swift-evolution] [Pitch] Introduce user-defined dynamically "callable" types

Joe Groff jgroff at apple.com
Sat Nov 11 12:15:30 CST 2017



> On Nov 11, 2017, at 10:04 AM, Chris Lattner <sabre at nondot.org> wrote:
> 
> 
> 
>>> On Nov 11, 2017, at 6:29 AM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> below the fold as far as the rest of the language is concerned. You could just as well written what the importer synths up in Swift directly:
>>> 
>>> func foo(bar: String) {
>>> unsafeBitCast(objc_msgSend, to: @convention(c) (AnyObject, Selector, NSString) -> ().self)(self, "fooWithBar:", NSString(bar))
>>> }
>>> 
>>> and the rest of the language would be none the wiser.
>> 
>> Though, since you bring up objc_msgSend, the way it works in ObjC might be a better fit for Swift's name lookup model, since their keyword argument models are similar. If Swift had a 'method of last resort' like ObjC's
> 
> In fact, this is the subject of the next proposal that I will write up when I have time.

It seems to me like a dynamic method-of-last-resort feature would subsume this proposal. Out of curiosity, why would we need both?

-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171111/289969a1/attachment.html>


More information about the swift-evolution mailing list