Thanks. This is sort-of too verbose when use. I have no comments about how to define it, but when use it, can we just use:
ProcessArray(someintarray); ? The complier should be able to "specialize" it implicitly because it knows someintarray is array of integer? alternatively, how about this: var proc_ints: specialize ProcessArray<LongInt>; begin proc_ints(someintarray); end; use it without explicit specialize is best, however. 2013/9/4 Sven Barth <pascaldra...@googlemail.com> > 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 > > _______________________________________________ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal