.NET 4.0 中是否需要 DLR?

发布于 2024-11-25 02:13:37 字数 262 浏览 2 评论 0原文

我一直在考虑将 DLR 用于我的玩具语言,但我有点困惑。如果 .NET 4.0 具有 LINQ 表达式树、动态对象和“动态”类型,那么我们真的还需要 DLR 吗? DLR 提供了什么可以让我作为语言开发人员的生活更轻松

--- 编辑 ----

让我更好地解释一下我的问题。在 codeplex (dlr.codeplex.com) 上找到的 DLR 项目,现在还有必要吗?该 DLR 项目的所有功能是否都已融入 .NET 4 中?或者在 DLR 中还可以找到一些有价值的东西吗?

I'v been looking into using DLR for my toy language, and I'm a bit confused. If .NET 4.0 has LINQ Expression trees, Dynamic Objects and the "dynamic" type, then do we really need the DLR anymore? What does the DLR provide that would make my life easier as a language developer

--- Edit ----

Let me explain my question a bit better. The DLR project found on codeplex (dlr.codeplex.com), is there much of a need for that anymore? Are all the features of this DLR project rolled into .NET 4? Or is there something of value left to be found in DLR?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

冷夜 2024-12-02 02:13:37

在 DLR 的开发过程中,我们将其分为两部分 - 内层和外层。内层由调用站点缓存、扩展表达式树和元对象协议组成。所有这些都是为了并添加到 .NET 4.0 中的。

外层由托管 API、表达式树解释器、COM 互操作支持、用于调用 .NET 方法的可自定义重载解析器、用于大多数 DLR 操作的默认绑定器以及许多其他各种帮助程序组成。这些都没有随 .NET 框架一起提供,但仍然对您有用。在 .NET 4.0 上使用此功能时,它依赖于 .NET 4.0 附带的 DLR API。

外层也分为两部分 - 托管 API (Microsoft.Scripting.dll) 和其他所有内容 (Microsoft.Dynamic.dll)。如果您希望人们能够像托管 IronPython 和 IronRuby 一样托管您的语言,则可以定位 DLR 托管 API。您可以使用 Microsoft.Dynamic.dll 或仅从中提取有用的代码片段,而不是重新发明轮子。无论哪种情况,如果您想要最新版本,您都需要查看 IronPython/IronRuby 网站,因为 Microsoft 不再积极开发外层组件。

During the development of the DLR we split it into two parts - the inner layer and the outer layer. The inner layer consisted of call site caching, the extended expression trees, and the meta object protocol. All of that was intended to and was added to .NET 4.0.

The outer layer consisted of the hosting APIs, expression tree interpreter, COM interop support, a customizable overload resolver for calling .NET methods, a default binder for most of the DLR operations, and many other various helpers. None of this has shipped w/ the .NET framework but could still be useful to you. When using this on .NET 4.0 it relies upon the DLR APIs shipped w/ .NET 4.0.

The outer layer was also split into two parts - the hosting APIs (Microsoft.Scripting.dll) and everything else (Microsoft.Dynamic.dll). You can target the DLR hosting APIs if you want people to be able to host your language in the same way they host IronPython and IronRuby. And you could either use Microsoft.Dynamic.dll or just pull useful pieces of code from it rather than re-inventing the wheel. In either case if you want the latest version you'll need to check out the IronPython/IronRuby web sites as Microsoft is no longer actively developing the outer layer components.

猫腻 2024-12-02 02:13:37

它并没有完全回答你的问题,但我很有兴趣阅读 Jim Hugunin 不久前关于离开微软的消息。

他指出的一件事是,DLR 是我们在 .Net 4.0 中取得的许多进步背后的驱动力,您现在说这就是您可能不再需要 DLR 的原因。

编辑:链接到消息 - http://hugunin.net/microsoft_farewell.html

另一方面,我认为 DynamicSite 系统仍然是非常有价值的东西,但不一定是放在 CLR 本身中的重要东西。

第二次编辑:这确实是一个有趣的查询,我刚刚查看了 Codeplex 上的文档。正如您所陈述和澄清的那样,.net 4.0 CLR 确实实现了那些曾经使 DLR 变得特殊的东西;阅读 DLR 概述后,我认为基本上的想法是,使用 DLR 实现的内容具有比等待新版本框架更快地访问新功能的优势。

这可能没有实际意义,因为他们已经有一段时间没有发布新版本的 DLR 了!

另一个可能的优点是 DLR 中的 AST 有更多功能,但我承认我没有正确探索这一点:

共享 AST(表达式树)——这是核心支柱之一
德国航天中心。我们扩展了 LINQ 表达式树以包含控件
流程、分配等。我们还提供所有表达式的源代码
树 v1 和 v2(DLR 的新内容)。表达 Tres 是一部分
降低将语言移植到 .NET 的门槛,我们将它们用于
绑定器和 DynamicMetaObject 协议。

It doesn't quite answer your question but I was very interested to read Jim Hugunin's message about leaving Microsoft a while ago.

One of the things that he pointed out was that the DLR was the driver behind many of the nice advances we have in .Net 4.0 that you now say are the reason why you might not need the DLR anymore.

Edit: Link to the messsage - http://hugunin.net/microsoft_farewell.html

On the other hand, I think that the DynamicSite system is still something that's quite valuable to have, whilst not necessarily something important to put in the CLR itself.

2nd edit: this is an interesting query really, I've just been looking at the docs on Codeplex. As you state and clarified, the .net 4.0 CLR does implement the kind of things that used to make the DLR special; Reading the DLR overview, I think that basically the idea is that things that are implemented with the DLR have the advantage of getting access to new features more quickly then waiting for a new version of the Framework.

This might be moot as they've not released a new version of the DLR for a while now!

Another possible advantage, but I admit I've not explored this properly, is that the AST in the DLR has more features:

Shared AST (Expression Trees) -- This is one of the core pillars of
the DLR. We have extended LINQ Expression Trees to include control
flow, assignment, etc. We also ship the sources for all of Expression
Trees v1 and v2 (the new stuff for the DLR). Expression Tres are part
of lowering the bar for porting languages to .NET, and we use them in
the binders and DynamicMetaObject protocols.

无可置疑 2024-12-02 02:13:37

正如此 wiki 页面 (http://en.wikipedia.org/wiki/Dynamic_Language_Runtime) 所解释的那样, DLR 与 IronPython 和 IronRuby 一起使用,所以是的,仍然需要它。

如果您可以使用更动态的语言进行开发,那么您的生活将会更轻松。

As this wiki page (http://en.wikipedia.org/wiki/Dynamic_Language_Runtime) explains, the DLR is used with IronPython and IronRuby, so yes, it is still needed.

It will make your life easier if you can use a more dynamic language for your development.

貪欢 2024-12-02 02:13:37

Codeplex 上的 DLR 是开源的,因此更容易进行改进/添加以支持您的语言可能需要的功能。

The DLR on codeplex is open source, so it's MUCH easier to make improvements/additions to support features your language may need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文