[fpc-pascal] Generic type parameter variable initialization

Sven Barth pascaldragon at googlemail.com
Thu Jan 5 15:17:00 CET 2012


Am 05.01.2012 15:03, schrieb Florian Klämpfl:
> Am 05.01.2012 14:19, schrieb Sven Barth:
>>> procedure TMyClass<T>.SomeMethod;
>>> var
>>>     V: T;
>>> begin
>>>     ...
>>>     Finalize(V);
>>>     FillChar(V, SizeOf(V), 0);
>>>     ...
>>> end;
>>>
>>> which is equivalent but it doesn't look too elegant. I am using FPC
>>> 2.7.1 for Win32/64.
>>
>> For now you'll need to use this workaround solution.
>
> Has the workaround really the same effect? I really wonder why there is
> a need for default then ...

It should at least be sufficent for the most common cases:
* ordinals
* strings
* classes
* records (and objects)

I don't know about Variants though. The Delphi help isn't helping either ;)

Regards,
Sven




More information about the fpc-pascal mailing list