[fpc-devel] RIP NoGlobals
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Thu Sep 30 19:06:04 CEST 2010
Mattias Gärtner schrieb:
>> There are more things that prevent that, not in the least that almost
>> any source code error will result in lots of memory leaks from the
>> compiler.
>
> Ehm, are you saying, that the compiler must be restarted when there were
> errors, because it does not clean up properly?
The current intialization and finalization of global variables is not
easily checkable. At least I miss a documentation of all these
variables, that specifies which part of the existing code is responsible
for their cleanup. No such documentation is required when the global
variables are moved into classes, as far as possible, because then the
destructor is *definitely* responsible for the proper finalization of
all fields of the class.
The same applies to strings, where the use and ownership of copies of
static strings can not be determined easily.
The current code is full with nilling of variables, where proper
destruction/finalization of possibly existing heap objects might be
required. Again a problem with reusing global variables in various
contexts, what makes it impossible to assign them to concrete owners.
DoDi
More information about the fpc-devel
mailing list