[fpc-pascal] procedure that accept generic types?
Sven Barth
pascaldragon at googlemail.com
Wed Sep 4 09:05:22 CEST 2013
Am 04.09.2013 08:18, schrieb Xiangrong Fang:
> Hi There,
>
> I try to write a procedure with generic parameters, but failed:
>
> type
> generic TArray<T> = array of T;
>
> procedure ProcessArray(arr: TArray<T>);
> begin
> end;
>
>
> The compiler said "Generics without specialization cannot be used..."
>
> But if I specialize the parameter then this procedure is useless.
>
> Any ideas?
>
This is not yet supported. A proof of concept implementation exists
locally on my computer however. It will then look like this:
=== code begin ===
type
generic TArray<T> = array of T;
generic procedure ProcessArray<T>(arr: TArray<T>);
begin
end;
begin
// usage:
specialize ProcessArray<LongInt>(someintarray);
end.
=== code end ===
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130904/054a3a1a/attachment.html>
More information about the fpc-pascal
mailing list