<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 5, 2017 at 4:30 AM, Chris Lattner via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> On Dec 4, 2017, at 5:22 PM, Joe DeCapo via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
>> The first one, has no static type info, no compile time checking, it's not self documenting, no type inference so people will be forced to use a dynamic reference at the call site to store the result, leading to more type loss, and all this spirals down.<br>
>> I'm already starting to fear dynamic.<br>
>> Edit: The danger has passed (Phew!) ... and dynamic wasn't been abused after all, no need to down vote me after 3 years :)<br>
><br>
> From what I can gather, `dynamic` is used when declaring types, but there's no indication at call sites that what is being invoked is dynamic. And it even allows for casting basically anything to the `dynamic` type.<br>
><br>
> <a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/dynamic" rel="noreferrer" target="_blank">https://docs.microsoft.com/en-<wbr>us/dotnet/csharp/language-<wbr>reference/keywords/dynamic</a><br>
><br>
> So here we have a language community that was (is?) very vocal about caution when it comes to type inference with `var`, but seems to have accepted the validity of `dynamic`. This seems to show that at least one community has absorbed this sort of change (arguably a more "dangerous" version than what is being proposed here) with no real issues.<br>
<br>
</span>Right. dynamic in C# is far broader (and more “dangerous”) than what I’m proposing. That said, because there have been absolutely zero specific examples of the sorts of harm DynamicMemberLookup could cause, it is difficult to speculate about exactly which boogieman people are afraid of.<br>
<span class=""><br>
> So I have a few questions:<br>
><br>
> - Would it be enough to require annotation of the dynamic nature of a type at the declaration sites, if that still means the call sites aren't explicitly annotated?<br>
<br>
</span>It is impossible to solve a problem if it cannot be explained in enough detail to provide examples. Personally, I don’t see the problem at all.<br>
<span class=""><br>
> - Why do some think the Swift community would be more at risk of abuse of this feature than the C# community seems to have been?<br>
<br>
<br>
</span>People are making bizarre claims about what the spirit of Swift is, informing me of things which are obviously not true, and ignoring the evidence I present to them. This is doubly humorous given that I have a fairly good sense for the design balance and tradeoffs of existing features in Swift today, along with detailed rationale for why they were added, when, and all of the discussion that backed them. I chalk this up to the fear of the unknown or perhaps a mistrust for the peers these people work with.<br></blockquote><div><br></div><div>For what i'm concerned, let's be very clear : i do not consider my personal opinion to matter AT ALL compared to what people like you, who code compilers for a living, think. And i feel even more embarrassed participating in that conversation since it's about a language you invented. I've only done it because people in the core team said it would be interesting.<br></div><div>Now, the only area where I may have more experience than people like you, is working with the average programmer, in the industry. And my personal experience shows that what a language doesn't enable is as important as what it enables (because every feature that can be abused will be, eventually and in ways nobody can expects).</div><div><br></div>Regarding your proposal regarding the impact it could have on pure swift, i think it comes down to letting the developer masquerade dictionaries into proper structs or classes. I tried to recreate a dynamic BaseDynamicObject based on dictionaries and your new protocols, but it's pretty hard without the finished implementation (i will try to recompile swift using your pull request wheneve i got the time, if i feel people are sincerely interested). <br></div><div class="gmail_quote">The "benevolent" purpose for doing that would be anything regarding mocking, proxying, mixins objects and their properties. There are various examples of those patterns in every dynamic languages. <br></div><div class="gmail_quote"><br></div><div class="gmail_quote">About C#, in which i did program a few years ago (but before dynamic was in the language), it already had powerful metaprogramming and introspection capabilities, as well as very convenient generics and interfaces ( easier to work with than what swift offers today, but that was a long time ago so my memory may be wrong). So, in some way, the potential for abusing dynamic or "stringly typed" programming was a lot lower. <br></div><div class="gmail_quote"><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
My goal is to make the design and proposal writeup as good as possible, and the fear mongering about abuse has led me to add several options for further narrowing the potential for abuse, including to the point of requiring every new adoptee to go through the Swift evolution process for review. During the review period for DynamicMemberLookup, people who carry these concerns are welcome to +1 one or more of those.<br>
<br>
I personally am far more interested in getting to the bottom of Doug’s concerns - it isn’t clear to me what exactly his preferred direction actually is, but that discussion is based on engineering tradeoffs and may well lead to a change to the proposal or a complete change in direction.<br>
<br>
-Chris<br>
<div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</div></div></blockquote></div><br></div></div>