Re: Delphi and the .Net platform



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.
.



Relevant Pages

  • Re: GC performance - GC fragility
    ... I rather prefer to know the details, but having not to care about them during coding. ... which does nothing more than allocating memory in an endless loop doesn't eat all the systems memory. ... For these kind of resources even in a GC environment reference counting is needed. ... If my application has a significant performance decrease, when using .NET compare to the native implementation then yes, I wouldn't let the customer pay for it. ...
    (borland.public.delphi.non-technical)
  • Re: OT - American Red Cross was OT - Katrina - Military Swings Into Action
    ... What I've been saying is that we are not taking care of our own country's needs. ... We have people here with no healthcare and we are closing hospitals daily, yet we are building brand new state-of-the art ones in Iraq. ... I believe that my concern for America first and foremost is patriotic and a strong America will enable us to be a stronger world power. ... We are weakening ourselves by misdirecting our resources and part of those resources are our young ...
    (rec.outdoors.rv-travel)
  • Re: What Happens?
    ... home and Medicaid would pay the bill if the person's resources were ... the person would not be just left to die ... through speech of writing, and had resources to pay for care, they ...
    (soc.retirement)
  • Re: What Happens?
    ... home and Medicaid would pay the bill if the person's resources were ... the person would not be just left to die ... through speech of writing, and had resources to pay for care, they ...
    (soc.retirement)
  • Re: What Happens?
    ... home and Medicaid would pay the bill if the person's resources were ... the person would not be just left to die ... through speech of writing, and had resources to pay for care, they ...
    (soc.retirement)