<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 27, 2016, at 1:26 PM, Jordan Rose via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hey, all. An engineer at Apple noticed the following behavior:<div class=""><br class=""></div>1. class Foo: NSObject → exposed to Objective-C, Swift-style (mangled) runtime name<br class="">2. @objc class Foo: NSObject → exposed to Objective-C, Swift-style (mangled) runtime name<div class="">3. @objc(Foo) class Foo: NSObject → exposed to Objective-C, unmangled runtime name</div><div class=""><br class=""></div><div class="">(and 4. @objc class Foo → illegal, classes must have ObjC heritage to be @objc.)</div><div class=""><br class=""></div><div class="">They specifically observed that (1) and (2) have the same behavior, and suggested that maybe (2) should be shorthand for (3).</div></div></div></blockquote><div><br class=""></div><div>I actually wonder why NSObject subclasses magically appear in the generated header when they aren’t marked @objc. If anything I’d say we should remove that behavior.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Pros:</div><div class="">- There aren't two ways to spell (1).</div><div class="">- Removing the mangling (and module uniquing) from the runtime name is probably one of the most common uses of @objc on a class.</div></div></div></blockquote><div><br class=""></div><div>Another really common case (at least in our mixed codebase) is bridging to give the class a “private” name in Swift but a sensible name in Objective-C because we have a sensible struct or generic type in Swift, don’t want Swift consumers to use the @objc type, yet need to provide a bridged interface to Objective-C. We do the same with methods too.</div><div><br class=""></div><div>@objc(Tile)</div><div>public class _objc_Tile: NSObject { }</div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Cons:</div><div class="">- It's a source-breaking change, for all that the "@objc" in (2) is redundant.</div><div class="">- For protocols, (1) and (2) are <i class="">not</i> equivalent, because @objc isn't inherited there.</div></div></div></blockquote><div><br class=""></div><div>I’d favor consistency even if (1) and (2) are redundant.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">- Mangling is used to namespace class names at run time; if you drop that, the ObjC name should probably have a prefix. (This applies more to frameworks than apps, though.)</div><div class=""><br class=""></div><div class="">There are probably people who say that last con applies to the generated header as well: we shouldn't put (1) or (2) into the generated header because the ObjC name might conflict with another class at <i class="">compile</i> time. This is valid, but probably too drastic a change at this point.</div><div class=""><br class=""></div><div class="">So, what does everyone think? I'm leaning towards "no change" because it's a bit subtle and not a big enough win, but if there's widespread support for this I'll pull it into a proposal.</div><div class=""><br class=""></div><div class="">Jordan</div></div></div></blockquote><br class=""></div><div>Given other priorities I’d lean toward no change.</div><div><br class=""></div><div>Russ</div><br class=""></body></html>