What changes were made to the CLR to support dynamic?
As I understand it, the .net 4.0 CLR needed to make changes to support the Dynamic Language Runtime.
Is there a way to see what those changes were? I noticed that the .net sta开发者_如何学Cndard does not mention things like DynamicObject - all these things seem to be part of the DLR. But if the DLR is "just a library", then there would be no need for .net 4 to run it.
So I'm just curious what changed in .net 4 to support the DLR.
No changes, it is just a library. The .NET 4.0 CLR wasn't needed, the DLR powered IronPython and IronRuby on the 2.0 version. You can have a look-see at what makes it tick from that version, you can download the source code from here. This code was moved into System.Core.dll largely unchanged.
Beware that there's rather a lot of it. It is all straight C#. It uses existing support in the CLR for dynamic binding through Reflection and COM interop. Its claim to fame is that it can do so by paying for that cost only once. It caches the results of a bind so that it is available at low cost in subsequent binds.
Adding the DLR interface glue to C# version 4 was a considerable effort in itself, embedded in Microsoft.CSharp.dll with lots of work in the compiler. That source code isn't available but you can sniff it with Reflector.
精彩评论