<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><blockquote type="cite" class="">On Nov 10, 2017, at 2:57 PM, Joe Groff <<a href="mailto:jgroff@apple.com" class="">jgroff@apple.com</a>> wrote:<br class=""></blockquote><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">On Nov 10, 2017, at 12:37 PM, Charles Srstka <<a href="mailto:cocoadev@charlessoft.com" class="">cocoadev@charlessoft.com</a>> wrote:<br class=""><br class=""><blockquote type="cite" class="">On Nov 10, 2017, at 12:04 PM, Joe Groff via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">I don't like the idea of some calls having wildly different semantics from others; it's difficult enough to tell what exactly a call might be doing already. Since we also lack the more obvious static "Callable" protocol idea to give even well-typed call syntax to user-defined types, this also seems like it'd be easily abused for that purpose too.<br class=""></blockquote><br class="">We already have that though, with the Objective-C bridge. How is the proposed behavior here more wildly different than the semantics of non-@objc, @objc, and @objc dynamic calls?<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">The language semantics aren't any different for non-@objc or @objc calls. The dispatch mechanism is an implementation detail. `dynamic` admits the possibility of late binding to change the method implementation dynamically, but doesn't change the type system behavior of the method, or radically change the implementation mechanism; it's still ultimately an indirect call, it doesn't turn your argument list into a dictionary that can be arbitrarily interpreted by user code.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">-Joe</span></div></div></blockquote></div><br class=""><div class="">You sure about that? ;-)</div><div class=""><br class=""></div><div class="">MyObject.h:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27); background-color: rgb(255, 255, 255);" class=""><span style="color: #78492a" class="">#import </span><Foundation/Foundation.h></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">@interface</span> MyObject : <span style="color: #703daa" class="">NSObject</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class="">@property<span style="color: #000000" class=""> (</span>nonatomic<span style="color: #000000" class="">, </span>copy<span style="color: #000000" class="">) </span>void<span style="color: #000000" class=""> (^callback)(</span><span style="color: #703daa" class="">NSDictionary</span><span style="color: #000000" class=""> *);</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class="">@end</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">@interface</span> MyObject (MyCategory)</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">- (<span style="color: #ba2da2" class="">void</span>)foo:(<span style="color: #703daa" class="">NSString</span> *)foo bar:(<span style="color: #703daa" class="">NSString</span> *)bar;</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class="">@end</div></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;" class="">MyObject.m:</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><div style="color: rgb(209, 47, 27); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="color: #78492a" class="">#import </span>"MyObject.h"</div><div style="color: rgb(186, 45, 162); font-family: Helvetica; font-size: 12px; margin: 0px; font-stretch: normal; line-height: normal; min-height: 14px;" class=""><br class=""></div><div style="color: rgb(186, 45, 162); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class="">@implementation<span style="color: #000000" class=""> MyObject</span></div><div style="color: rgb(186, 45, 162); font-family: Helvetica; font-size: 12px; margin: 0px; font-stretch: normal; line-height: normal; min-height: 14px;" class=""><br class=""></div><div style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class="">- (<span style="color: #ba2da2" class="">void</span>)baz:(<span style="color: #703daa" class="">NSString</span> *)baz qux:(<span style="color: #703daa" class="">NSString</span> *)qux {}</div><div style="color: rgb(186, 45, 162); font-family: Helvetica; font-size: 12px; margin: 0px; font-stretch: normal; line-height: normal; min-height: 14px;" class=""><br class=""></div><div style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class="">- (<span style="color: #703daa" class="">NSMethodSignature</span> *)methodSignatureForSelector:(<span style="color: #ba2da2" class="">SEL</span>)selector {</div><div style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""> <span style="color: #ba2da2" class="">if</span> (selector == <span style="color: #ba2da2" class="">@selector</span>(foo:bar:)) {</div><div style="color: rgb(62, 30, 129); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="color: #000000" class=""> </span><span style="color: #ba2da2" class="">return</span><span style="color: #000000" class=""> [</span><span style="color: #ba2da2" class="">super</span><span style="color: #000000" class=""> </span>methodSignatureForSelector<span style="color: #000000" class="">:</span><span style="color: #ba2da2" class="">@selector</span><span style="color: #000000" class="">(baz:qux:)];</span></div><div style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""> } <span style="color: #ba2da2" class="">else</span> {</div><div style="color: rgb(62, 30, 129); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="color: #000000" class=""> </span><span style="color: #ba2da2" class="">return</span><span style="color: #000000" class=""> [</span><span style="color: #ba2da2" class="">super</span><span style="color: #000000" class=""> </span>methodSignatureForSelector<span style="color: #000000" class="">:selector];</span></div><div style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""> }</div><div style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class="">}</div><div style="color: rgb(186, 45, 162); font-family: Helvetica; font-size: 12px; margin: 0px; font-stretch: normal; line-height: normal; min-height: 14px;" class=""><br class=""></div><div style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class="">- (<span style="color: #ba2da2" class="">void</span>)forwardInvocation:(<span style="color: #703daa" class="">NSInvocation</span> *)invocation {</div><div style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""> <span style="color: #703daa" class="">NSString</span> *name = <span style="color: #3e1e81" class="">NSStringFromSelector</span>(invocation.<span style="color: #703daa" class="">selector</span>);</div><div style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="color: #000000" class=""> </span>NSMutableArray<span style="color: #000000" class=""> *args = [</span>NSMutableArray<span style="color: #000000" class=""> </span><span style="color: #3e1e81" class="">new</span><span style="color: #000000" class="">];</span></div><p style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal; min-height: 16px;" class=""> <br class="webkit-block-placeholder"></p><div style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="color: #000000" class=""> </span><span style="color: #ba2da2" class="">for</span><span style="color: #000000" class=""> (</span>NSUInteger<span style="color: #000000" class=""> i = </span><span style="color: #272ad8" class="">2</span><span style="color: #000000" class="">; i < invocation.</span>methodSignature<span style="color: #000000" class="">.</span>numberOfArguments<span style="color: #000000" class="">; i++) {</span></div><div style="color: rgb(186, 45, 162); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="color: #000000" class=""> </span>__unsafe_unretained<span style="color: #000000" class=""> </span>id<span style="color: #000000" class=""> obj = </span>nil<span style="color: #000000" class="">;</span></div><p style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal; min-height: 16px;" class=""> <br class="webkit-block-placeholder"></p><div style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""> [invocation <span style="color: #3e1e81" class="">getArgument</span>:&obj <span style="color: #3e1e81" class="">atIndex</span>:i];</div><p style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal; min-height: 16px;" class=""> <br class="webkit-block-placeholder"></p><div style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""> [args <span style="color: #3e1e81" class="">addObject</span>:obj];</div><div style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""> }</div><p style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal; min-height: 16px;" class=""> <br class="webkit-block-placeholder"></p><div style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""> <span style="color: #ba2da2" class="">self</span>.<span style="color: #4f8187" class="">callback</span>(<span style="color: #272ad8" class="">@{</span> <span style="color: #d12f1b" class="">@"name"</span> : name, <span style="color: #d12f1b" class="">@"arguments"</span> : args <span style="color: #272ad8" class="">}</span>);</div><div style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class="">}</div><div style="color: rgb(186, 45, 162); font-family: Helvetica; font-size: 12px; margin: 0px; font-stretch: normal; line-height: normal; min-height: 14px;" class=""><br class=""></div><div style="color: rgb(186, 45, 162); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class="">@end</div><div style="color: rgb(186, 45, 162); font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">main.swift:</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="color: #ba2da2" class="">import</span> Foundation</div><div style="margin: 0px; font-stretch: normal; line-height: normal; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="color: #ba2da2" class="">let</span> obj = <span style="color: #4f8187" class="">MyObject</span>()</div><div style="margin: 0px; font-stretch: normal; line-height: normal; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);" class="">obj<span style="color: #000000" class="">.</span>callback<span style="color: #000000" class=""> = { dict </span><span style="color: #ba2da2" class="">in</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""> <span style="color: #3e1e81" class="">print</span>(<span style="color: #d12f1b" class="">"got this dictionary: </span>\<span style="color: #d12f1b" class="">(</span>dict <span style="color: #ba2da2" class="">as</span>? [<span style="color: #703daa" class="">String</span> : <span style="color: #ba2da2" class="">Any</span>] ?? [:]<span style="color: #d12f1b" class="">)"</span>)</div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-stretch: normal; line-height: normal; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="color: #4f8187" class="">obj</span><span style="color: #000000" class="">.</span><span style="color: #31595d" class="">foo</span><span style="color: #000000" class="">(</span>"Foo"<span style="color: #000000" class="">, bar: </span>"Baz”<span style="color: #000000" class="">)</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;" class="">Charles</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div></div></div></body></html>