简体   繁体   English

在Delphi 2009中使用泛型和匿名方法有什么问题?

[英]What problems are there using generics and anonymous methods in Delphi 2009?

I'd like to start using generics and anonymous method, mainly to learn what that's all about and why I would want to use them. 我想开始使用泛型和匿名方法,主要是为了了解这是什么以及为什么我想要使用它们。

Having Delphi 2009, I often read that generics and anonymous methods are not completely implemented or buggy, which was fixed in Delphi 2010. 有了Delphi 2009,我经常读到泛型和匿名方法没有完全实现或有缺陷,这在Delphi 2010中得到了修复。

I would like to avoid having to wonder if it's my fault or a bug in Delphi 2009, every time something doesn't work as I expect. 我想避免不得不怀疑这是我的错,还是Delphi 2009中的一个错误,每当某些东西不能像我期望的那样工作时。

My question is: 我的问题是:
What exactly are the problems I will have when using generics and anonymous methods in Delphi 2009? 在Delphi 2009中使用泛型和匿名方法时,我会遇到什么问题?
What should I avoid? 我应该避免什么?

What problems will you have? 你有什么问题? Well, if everything compiles, then you're usually fine. 好吧,如果一切都编译好,那么你通常都很好。 It's not a bad codegen issue, more of a no codegen issue. 这不是一个糟糕的codegen问题,更多的是没有 codegen问题。 It's that creating actual code from the generic templates tends to lead the compiler into dark corners and you get internal errors. 从通用模板创建实际代码往往会导致编译器陷入黑暗的角落,并且会出现内部错误。

What should you avoid? 你应该避免什么? At the risk of sounding snarky, what you should avoid is trying to use generics in D2009 and expecting them to work. 冒着听起来很危险的风险,你应该避免的是试图在D2009中使用泛型并期望它们起作用。 Update 3 fixed a lot of things, but not everything. 更新3修复了很多东西,但不是一切。 Delphi 2010 fixed a lot more, and generics are mostly usable now, unless you're trying to mix generics with packages. Delphi 2010修复了很多,而且泛型现在大部分都可用,除非你试图将泛型与包混合。 They're still working on getting that part right. 他们仍在努力使这一部分正确。 At this point, I'd recommend just waiting a few more weeks (presumably) until the next version comes out and upgrade. 在这一点上,我建议等待几周(大概),直到下一个版本出来并升级。 With any luck they'll have generics working as solidly as the rest of the system. 运气好的话,他们会让仿制药和其他系统一样稳固。

You can use Quality Central . 您可以使用Quality Central It lets you search on specific criteria (like version) and keywords to show you any problems that have been reported and their status. 它允许您搜索特定条件(如版本)和关键字,以显示已报告的任何问题及其状态。 Remember that some of the closed items might have been fixed in a later release. 请记住,某些已关闭的项目可能已在以后的版本中修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM