<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 Dec 3, 2017, at 5:14 PM, Chris Lattner &lt;<a href="mailto:clattner@nondot.org" class="">clattner@nondot.org</a>&gt; 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=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 3, 2017, at 2:44 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="Singleton"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" 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=""><div class=""><div style="word-wrap: break-word;" class=""><div class=""><div class=""><br class="Apple-interchange-newline">and you don’t realize that PyVal’s are involved.&nbsp; However, if you are actively writing the code, you have access to code completion and other things that tell you these types, and if it is important for the clarity of the code, you write this instead:</div><div class=""><br class=""></div><div class=""><div class=""><span class="m_2215210071369923463Apple-tab-span" style="white-space: pre-wrap;">        </span>let x :PyVal = foo()[“someKey”]</div><div class=""><br class=""></div><div class="">There is nothing specific to this proposal about this issue.</div></div></div></div></div></blockquote><div 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 class=""></div><div 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="">See above.&nbsp; In the case of PyVal specifically the concern is somewhat mitigated by the name of the type.&nbsp; That won’t necessarily always be the case.</div></div></div></blockquote><div class=""><br class=""></div><div class="">If that's the concern, then it would be pretty straightforward to restrict dynamic protocols for stdlib internal use only and expose only PyVal. The trade-off is that all such bridging code would have to be shipped with Swift itself.</div></div></div></div></div></div></blockquote><div class=""><br class=""></div>Right, this is specifically mentioned as option #2 in the proposal:</div><div class=""><a href="https://gist.github.com/lattner/b016e1cf86c43732c8d82f90e5ae5438#reducing-potential-abuse" class="">https://gist.github.com/lattner/b016e1cf86c43732c8d82f90e5ae5438#reducing-potential-abuse</a></div><div class=""><br class=""></div><div class="">It sounds like Matthew’s concerns can be addressed by him +1’ing that alternative when it comes up for review.</div></div></div></blockquote><div><br class=""></div><div>FWIW, another thought along these lines which would go even further in addressing my concerns would be to isolate PyVal and other dynamic types provided as part of Swift itself in a separate module which must be imported and linked against. &nbsp;That would give teams an easy way to opt-out of these types being available in their code base in a centralized fashion. &nbsp;</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=""><blockquote type="cite" class=""><div class=""><div class="Singleton"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word;" class=""><div class="">You miss my point.&nbsp; My point is that AnyObject lookup was carefully considered, has stood the test of time, and is the *right* answer.&nbsp; Swift 1 would not have been nearly as successful without it.</div></div></div></blockquote><div class=""><br class=""></div><div class="">I don’t think I do.&nbsp; I was trying to agree with exactly the point that it was the right answer in the early days of Swift and getting it right then was essential to Swift’s success. &nbsp;</div></div></div></blockquote></div></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Ok, but the “early days of Swift” are directly analogous to the present days of other dynamic languages. &nbsp;</div><br class=""><blockquote type="cite" class=""><div class=""><div class="Singleton"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><div class=""><br class=""></div><div class="">Aside from the historical necessity of AnyObject, it is also a very specific and widely know type that doesn’t have<span class="Apple-converted-space">&nbsp;</span><i class="">any</i>&nbsp;statically available members at all and only looks up @objc members.&nbsp; These properties help to reduce the risk that somebody misunderstands what is going on.</div></div></div></blockquote><div class=""><br class=""></div><div class="">I imagine we could restrict all such dynamic types from having any statically available members without losing much.</div></div></div></div></div></div></blockquote></div><br class=""><div class="">This isn’t practical. &nbsp;We need some traditionally defined members so that PyVal can conform to standard protocols, like ExpressibleByIntegerLiteral and many others.</div><div class=""><br class=""></div><div class="">-Chris</div><div class=""><br class=""></div></div></div></blockquote></div><br class=""></body></html>