Re: D8: first impression and uneasy feeling... (long)

From: Jon Shemitz (jon_at_midnightbeach.com)
Date: 02/22/04


Date: Sat, 21 Feb 2004 18:20:52 -0800


"Nick Hodges (TeamB)" wrote:

> > BTW, the whole purpose of garbage collecting is freeing
> > *resources*, not just memory. If it leaves dangling file
> > handles open, it's not worth its money.
>
> That's correct -- but GC is specifically for memory. Closing and
> protecting resources like files, etc., has to be up to the programmer.

This is an overstatement. The GC is quite capable of calling
finalizers to close files &c, it's just that they will stay open a
while, and the resurrection costs are not insignificant. It's not that
you HAVE to explicitly Close and Dispose of resources, it's that you
should.
 
> Hence, even when coding in Delphi, I am going to continue to call
>
> <create>
> try
> ...
> finally
> <free>
> end;
>
> Even when I don't explicitly have to. Good habits make for good code.

Sing it with me, brethren, "Oh Spirit of Portability, to thee a tax
upon my productivity."

-- 
programmer, author  http://www.midnightbeach.com
and father          http://www.midnightbeach.com/hs


Relevant Pages