什么是托管类型?它们是特定于 Delphi 的吗?它们是特定于 Windows 的吗?
总结:
请查看下面的知识性评论。
=================================================== ============
我在很多 stackoverflow Delphi 主题中都看到过托管类型这一术语。例如,正确初始化/终结
主题中提到了它。但是,当我用 google 搜索托管类型
时,似乎大多数链接都与 C++ 或 .NET 相关。例如,请参阅 MSDN 页面 。有人可以帮忙评论一下 Delphi 中定义的托管类型吗?鉴于 Delphi for POSIX/MacOS 即将诞生,托管类型是否特定于 Windows?感谢您提前付出的努力和时间!
PS:正确初始化/终结
的主题:
在 Delphi 中哪些变量会被初始化?
delphi 变量默认使用值初始化吗?
我应该如何释放数组Delphi 7 析构函数中的对象数量?
在 Delphi 2009 中我需要释放变体数组吗?< /a>
Summarization:
Please check the knowledgeable comments below.
==============================================================
I have seen the term of managed types
mentioned in quite a few stackoverflow Delphi topics. For example, it is mentioned in topics of correctly initializing/finalizing
. However, when I google managed types
, it seems most links are related to C++, or .NET. For example, see the MSDN page. Could some one help to comment what are managed types defined in Delphi? Given that Delphi for POSIX/MacOS is being born, are managed types specific to Windows? Thanks for your effort and time in advance!
PS: Topics of correctly initializing/finalizing
:
Which variables are initialized when in Delphi?
Are delphi variables initialized with a value by default?
How should I free an array of objects in a Delphi 7 destructor?
In Delphi 2009 do I need to free variant arrays?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在
Delphi
上下文中,托管类型是 Delphi 编译器自动为其生成生命周期管理代码的类型。这包括:Open动态数组因为
Delphi
上下文中的托管类型是根据以下内容定义的Delphi 编译器生成的内容是特定于 Delphi 的。在 .NET 世界中,开发人员不需要管理已分配内存的生命周期,因为 .NET 提供了一种自动机制来执行此操作:垃圾收集器。但是 .NET 包含处理 CLR 之外的事物的能力(例如:使用不针对 CLR 的本机 DLL)。该代码通常被称为未修改且不安全的。
在 .NET 上下文中,托管涉及 CLR 自动管理的内容,因此这是 .NET 特定术语!
In the context of
Delphi
, managed types are those types for whom the Delphi Compiler automatically generates lifecycle management code. This includes:OpenDynamic ArraysBecause managed types in the
Delphi
context are defined in terms of what the Delphi compiler generates, they're delphi-specific.In the .NET world the developer doesn't need to manage the lifecycle of allocated memory because .NET provides an automatic mechanism for doing this: The Garbage Collector. But .NET includes the ability to work with things outside the CLR (example: using native DLL's that don't target the CLR). That code is usually called unamanged and unsafe.
In the context of .NET managed relates to what the CLR automatically manages, so that's .NET specific term!
请参阅Barry Kelly 对相关主题的回答。
由于托管类型是一种语言功能,因此 Mac OS 等不应有重大变化。
See Barry Kelly's answer to a releated thread.
Since managed types are a language feature there shouldn't be significant changes on Mac OS et al.