[fpc-pascal] procedure that accept generic types?
Sven Barth
pascaldragon at googlemail.com
Wed Sep 4 09:49:03 CEST 2013
Am 04.09.2013 09:41, schrieb Xiangrong Fang:
> Hi Sven,
>
> Not to "debate" the syntax, but just ask :-)
>
> 1) in my second example: proc_ints: specialize ProcessArray<LongInt>;
> it is "specialized". Why this is still not consistent ?
You declared "proc_ints" as a variable and specialized a procedure. That
is not correct from the typing point of view. We'd either need a new
section type for procedure/function specializations or we ensure that
the following works:
=== code begin ===
type
generic TArrayProc<T> = procedure(arr: TArray<T>);
var
proc_ints: specialize TArrayProc<LongInt> = @specialize
ProcessArray<LongInt>;
=== code end ===
>
> 2) in delphi mode, "specialize" is not required anywhere, right? If
> so, can you write an example of your new proposal in delphi mode?
> btw, my last experience with Delphi is 6 or 7, there was no generics yet.
The same just without "generic" and "specialize". This is then Delphi
compatible (except the fact that Delphi does not support global generic
functions/procedures, but only generic methods).
Regards,
Sven
More information about the fpc-pascal
mailing list