[fpc-pascal] procedure that accept generic types?

Xiangrong Fang xrfang at gmail.com
Wed Sep 4 09:41:58 CEST 2013


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 ?

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.

Thanks



2013/9/4 Sven Barth <pascaldragon at googlemail.com>

>  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
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130904/cf7ba179/attachment.html>


More information about the fpc-pascal mailing list