[fpc-pascal] procedure that accept generic types?
Sven Barth
pascaldragon at googlemail.com
Wed Sep 4 09:37:14 CEST 2013
Am 04.09.2013 09:13, schrieb Xiangrong Fang:
> 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); ?
No. Generics are specialized with "<SomeType>", so not using it for
procedures/functions/methods as well is inconsistent.
>
>
> 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.
No. In non-Delphi modes specializations require "specialize". This is
for consistency of the language and also for simplification of the
parser in those modes.
And just in case: The syntax is not up to debate.
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130904/09aadb51/attachment.html>
More information about the fpc-pascal
mailing list