[fpc-devel] Status of Generic Functions

Kornel Kisielewicz kornel.kisielewicz at gmail.com
Sat May 19 12:58:51 CEST 2012


On Sat, May 19, 2012 at 10:50 AM, David Ballesteros <dballesg at gmail.com> wrote:
> Hi,
>
> I'm trying to port a C/C++ SDK from an application to a Pascal Wrapper using
> FPC 2.7.1. from SVN.
>
> I have a templated fucntion on the C++ code that I will like to translate, I
> know Generic classes are more or less working on the FPC SVN.
>
> To my surprise this two lines of code doesn't produce any compiling errors:
>
> type
>   generic test<M,N>  = procedure( m1 : M; n1 : N);
>   generic test2<M,N> = function( m1 : M; n1 : N): Boolean;
>
> But how to write the implementation?
>
> This means the FPC parser understand it but they will not compile?

That's not surprising at all. What you are doing here is defining a
generic of a procedural variable type. Hence this is only useful to
specialize to a given type (which is useful in some generic classes,
for example to define a sorter function in a linear container). That
is a completely different situation than defining a generic procedure
itself. That is as yet (as far as I know) not possible.
-- 
regards,
Kornel Kisielewicz
http://chaosforge.org/



More information about the fpc-devel mailing list