<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">According to Swift docs on AnyObject,</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">The protocol to which all classes implicitly conform.</blockquote></blockquote><div class="gmail_default" style="font-family:georgia,serif;display:inline">​So it is not ​</div><span style="font-size:13px">an explicit conformance.<div class="gmail_default" style="font-family:georgia,serif;display:inline">​</div></span><div><span style="font-size:13px"><div class="gmail_default" style="font-family:georgia,serif;display:inline"><br></div></span></div><div><span style="font-size:13px"><div class="gmail_default" style="font-family:georgia,serif;display:inline">​<a href="http://swiftdoc.org/v2.1/protocol/AnyObject/">http://swiftdoc.org/v2.1/protocol/AnyObject/</a></div></span><br></div><div><span style="font-size:13px"><br></span></div><div>z<div class="gmail_default" style="font-family:georgia,serif;display:inline">​haoxin​</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 8, 2016 at 4:50 PM, Luke Howard via swift-dev <span dir="ltr">&lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">In the fix for [SR-381] (links at end) we implement an API for looking up classes by name by searching the protocol conformance table. The initial consumer of this is NSClassFromString() as used by NSKeyedUnarchiver in Foundation.<div><br></div><div>The limitation of this approach is that only classes that explicitly conform to protocols can be resolved. We’ll work around this in Foundation by having subclasses that otherwise inherit their protocol conformance explicitly conform to a dummy protocol. However, this behaviour is confusing and would be nice to fix.</div><div><br></div><div>One approach I’ve been playing with is for classes always to have an explicit conformance to AnyObject (at least, if they don’t explicitly conform to anything else). (I have a bit of a hacky patch to implement this but it’s failing at link time as there’s no symbol for “_TMps9AnyObject”.)</div><div><br></div><div>Before I proceed further down this path – is this an approach worth pursuing or would it be better not to abuse the conformance table for name lookups long term?</div><div><br></div><div><div>— Luke</div><div><br></div><div><a href="https://bugs.swift.org/browse/SR-381" target="_blank">https://bugs.swift.org/browse/SR-381</a></div><div><a href="https://github.com/apple/swift/pull/834/files" target="_blank">https://github.com/apple/swift/pull/834/files</a></div><div><br><div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="text-align:-webkit-auto;text-indent:0px;word-wrap:break-word"><div style="text-align:-webkit-auto;text-indent:0px;word-wrap:break-word"><span style="border-collapse:separate;border-spacing:0px"><div style="word-wrap:break-word"><span style="border-collapse:separate;text-indent:0px;border-spacing:0px"><div style="word-wrap:break-word"><div style="color:rgb(0,0,0);font-family:&#39;Akzidenz-Grotesk BQ&#39;;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-transform:none;white-space:normal;word-spacing:0px">--</div><div><font face="Akzidenz-Grotesk BQ" size="3"><a href="http://www.lukehoward.com" target="_blank">www.lukehoward.com</a><br><a href="http://soundcloud.com/lukehoward" target="_blank">soundcloud.com/lukehoward</a></font></div></div></span></div></span></div></div></div></div></div></div>
<img alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div>
<br>_______________________________________________<br>
swift-dev mailing list<br>
<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><br>Owen Zhao<br></div></div></div>
</div>