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

Chris Lattner sabre at nondot.org
Sat Nov 11 12:04:57 CST 2017



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

-Chris

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


More information about the swift-evolution mailing list