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
:
In the context of Delphi
, managed types are those types for whom the Delphi Compiler automatically generates lifecycle management code. This includes:
- Strings
OpenDynamic Arrays- Records containing other managed types
- Interfaces
- (later edit) Anonymous methods
- (later edit) Variants
Because 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!
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.
精彩评论