Re: Delphi and the .Net platform
- From: "Rudy Velthuis [TeamB]" <newsgroups@xxxxxxxxxxxx>
- Date: Sat, 22 Dec 2007 22:55:12 +0100
Wayne Niddery (TeamB) wrote:
Free was mapped in .Net specifically to allow migration of existing
VCL code without having to worry about the fact that GC exists and
having to adjust code everywhere to make it behave correctly under
.Net.
In that case, if could simply be a no-op, and all would be well. But it
was not designed to be a no-op. It was designed to do the same as in
Delphi for Win32: to take care of resources. In .NET, the most used
resource, memory, is already taken care of, but all other resources
must still be taken care of by the user, not by the platform. That is
why destructors map to IDisposable.Dispose and Free calls them, where
necessary.
If using the VCL for new development in .Net, I consider it
permissible to continue using Free as one should under Win32,
especially for those that need to jump back and forth between
platforms for various projects, but otherwise cannot consider it a
good practice.
I don't know if adopting different habits for .NET is good practice,
especially if you program for both platforms. And Free still HAS an
effect on unmanaged resources. It was not merely left in to allow
migration.
Good practice is to learn about the platform one is
working on and in this case that means learning that there is a GC
and learn to code accordingly.
Free has nothing to do with the GC. Free is meant to take care of
unmanged resources.
--
Rudy Velthuis [TeamB] http://www.teamb.com
"Never test for an error condition you don't know how to handle."
-- Steinbach's Guideline for Systems Programmers.
.
- Follow-Ups:
- Re: Delphi and the .Net platform
- From: Wayne Niddery \(TeamB\)
- Re: Delphi and the .Net platform
- References:
- Re: Delphi and the .Net platform
- From: Brian Moelk
- Re: Delphi and the .Net platform
- From: Troy Wolbrink
- Re: Delphi and the .Net platform
- From: Brian Moelk
- Re: Delphi and the .Net platform
- From: Troy Wolbrink
- Re: Delphi and the .Net platform
- From: Brian Moelk
- Re: Delphi and the .Net platform
- From: Dave Nottage [TeamB]
- Re: Delphi and the .Net platform
- From: Brian Moelk
- Re: Delphi and the .Net platform
- From: Dave Nottage [TeamB]
- Re: Delphi and the .Net platform
- From: Brian Moelk
- Re: Delphi and the .Net platform
- From: Dave Nottage [TeamB]
- Re: Delphi and the .Net platform
- From: Brian Moelk
- Re: Delphi and the .Net platform
- From: John Moshakis
- Re: Delphi and the .Net platform
- From: Brian Moelk
- Re: Delphi and the .Net platform
- From: Rudy Velthuis [TeamB]
- Re: Delphi and the .Net platform
- From: Joanna Carter [TeamB]
- Re: Delphi and the .Net platform
- From: Rudy Velthuis [TeamB]
- Re: Delphi and the .Net platform
- From: Joanna Carter [TeamB]
- Re: Delphi and the .Net platform
- From: Rudy Velthuis [TeamB]
- Re: Delphi and the .Net platform
- From: Wayne Niddery \(TeamB\)
- Re: Delphi and the .Net platform
- Prev by Date: Re: Delphi and the .Net platform
- Next by Date: Re: Delphi and the .Net platform
- Previous by thread: Re: Delphi and the .Net platform
- Next by thread: Re: Delphi and the .Net platform
- Index(es):
Relevant Pages
|