Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2012-05

Status of Generic Functions

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

David Ballesteros

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?

Any help and extra information will be appreciated. David

Reply by email

Kornel Kisielewicz
to David Ballesteros
David Ballesteros wrote 17 lines
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 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/

Reply by email

Sven Barth
to Kornel Kisielewicz
Kornel Kisielewicz wrote 25 lines
On Sat, May 19, 2012 at 10:50 AM, David Ballesteros 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 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.

Completely correct. Only one thing to add from my side:

I hope to start the implementation of generic functions/methods in this year.

Regards,
Sven

Reply by email

David Ballesteros
to Sven Barth

Thanks to both for the explanation. I see it now.

And thanks Sven dfor the note about the ETA of the generic functions/methods.

In the meantime I will see if I can do it in some other way.

Best regards,
David

2012/5/19 Sven Barth

Show quoted text 47 lines
On 19.05.2012 12:58, Kornel Kisielewicz wrote: > On Sat, May 19, 2012 at 10:50 AM, David Ballesteros > 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 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. > Completely correct. Only one thing to add from my side: I hope to start the implementation of generic functions/methods in this year. Regards, Sven ______________________________**_________________ fpc-devel maillist - http://lists.freepascal.org/**mailman/listinfo/fpc-devel<http://lists.freepascal.org/mailman/listinfo/fpc-devel>

Reply by email