[fpc-devel] Redefine FillChar() to use out parameter instead
florian at freepascal.org
Thu Nov 19 10:35:08 CET 2009
Graeme Geldenhuys schrieb:
> Florian Klaempfl wrote:
>>> I see many use-cases for out parameters
>> You mean for VAROUT parameters :)?
> I search the latest FP Language Reference document, and there is no
> mention of 'varout'. I also tried to use varout in a procedure as
> follows - which gave a compiler error with FPC 2.4.0-rc1
It is not implemented, but it would be the solution to the fillchar problem.
> procedure dcpFillChar(varout x; count: SizeInt; Value: Byte); overload;
> procedure dcpFillChar(out x; count: SizeInt; Value: Byte); overload;
> First one is not compilable, but the second one is. So no, I don't
> understand your comment about 'varout'? Please explain more.
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.
More information about the fpc-devel