[fpc-devel] Redefine FillChar() to use out parameter instead

"Vinzent Höfler" JeLlyFish.software at gmx.net
Thu Nov 19 20:43:02 CET 2009


Florian Klaempfl <florian at freepascal.org>:

> A VAROUT parameter could have the same semantics as VAR except that the
> compiler does not expect that it is needed that it is initialized. But
> be warned: with such a parameter type you can easily create memory leaks
> with automated types like ansistrings.

I don't understand the issue. Firstly, it's just a keyword. Secondly, the compiler should know if the actual type is reference counted or not.

So if the programmer can decide which keyword to use, why the hell should it be a problem for the compiler (which usually knows much better than the programmer)?

IMO, something like

-- 8< --
if Is_Reference_Counted (Type) then
   Parameter_Mode := Out_Ref;
else
   Parameter_Mode := Plain_Ref;
end if;
-- 8< --

can't be so hard to accomplish, can it?

I even thought, it's impossible for reference counted types to be uninitialized (in a purely technical way), because the compiler does the initialization automatically? Or how else can it rely on the associated reference count?


Vinzent.

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01



More information about the fpc-devel mailing list