close(file); always necessary??
samiam at moorecad.com
samiam at moorecad.com
Sat Jun 19 00:27:44 CEST 2010
Hence the reference count stuffs. I did a paper analysis once, I decided
that:
1. To do true automated storage recycling, you have to track each
pointer
leaving scope, which means that you have to know where every pointer is.
2. Be ready to reference count each pointer, that is, each copy
operation
increments the reference count, and each dynamic entry gets a reference
counter that is initially one for the pointer that is returned.
3. Decrement the reference counter each time any pointer leaves scope.
4. produce an error if the programmer attempts to free a non-zero
referred
pointer.
5. The whole thing generates headaches.
Seriously, it is quite doable with Pascal, but generates a lot of
overhead.
Each data structure needs a template for the contained pointers, and
every data structure leaving scope or freed must be analysed for
contained
pointers, and those pointers decrementing reference counts.
Wirth also described this scheme, although I don't think he ever tried
it.
I have thought about implementing it primarily to shut people up, i.e.,
lack of automated storage collection "is a problem with old languages
like Pascal". It isn't, the price paid for reclaimation overhead is the
same
as Java or other languages, we are primarily burdened by users who
expect true compiled performance code.
Scott
-------- Original Message --------
Subject: Re: close(file); always necessary??
From: Frank Heckenbach <ih8mj at fjf.gnu.de>
Date: Fri, June 18, 2010 2:56 pm
To: gpc at gnu.de
samiam at moorecad.com wrote:
> Then that would leave you pretty close to
> automatic dynamic storage recycling, no ?
Partly. When a pointer variable goes out of scope, we cannot
automatically dispose it, since copies may exist.
Fully automatic storage recycling still requries full-blown
reference counting or garbage collection, AFAICS.
Frank
--
Frank Heckenbach, f.heckenbach at fh-soft.de, http://fjf.gnu.de/, 7977168E
GPC To-Do list, latest features, fixed bugs:
http://www.gnu-pascal.de/todo.html
GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE D101 CD02 4C9D 0FE0
E5E8
More information about the Gpc
mailing list