[fpc-devel] Generics in FPC have many problems

Sven Barth pascaldragon at googlemail.com
Mon Aug 29 17:19:04 CEST 2011


Hi!

As Paul and Jonas already told you, I'm currently working on improving 
the compilers generic implementation. As you have noticed it currently 
doesn't support generic methods and constraints at all. Also the generic 
implementation in mode Delphi isn't working correctly as you've noticed. 
Inline specialications (those without using "type foobar = foo<bar>") 
don't work either.

For this I have found the following tasks:
* allow declaring and implementing generics with the Delphi syntax while 
keeping the FPC syntax supported (this is an important point regarding 
backwards compatibility); state: working
* allow the declarations of multiple generics with the same name (e.g. 
foo<t> =... foo <t, s> = ...); state: mostly working
* allow inline specializations; state: partly working inside 
implementations; inside declarations this needs to be tested
* allow nested specializations: not started
* allow nested generics: not started
* implement generic methods: not started
* implement constraints: not started

My plan is to merge the changes from my branch to trunk after the first 
three points are done (the third one at least mostly as inline 
specializations are rather fragile) to reduce the differences between 
those to branches. Then I'll start working on either generic methods or 
constraints (depends on my mood then).

Please keep in mind that working on the generics feature isn't an easy 
task, so I can't give you an estimate when the one or other improvement 
will be available.

If you want you can test around with my branch, but please keep in mind 
that it's a work in progress and that compilation of the compiler or the 
RTL might also be broken from time to time (currently the fgl unit 
doesn't compiler for example).

> And if someone ever does intent to fix generics in FPC, there are a whole slew of errors that they already bring into the compiler. I'll make a list of examples of those errors at a later time, but they inner workings of generics should be redone to remove the specialization requirement before those errors are addressed.

If you do such an error list then please provide a single program for 
each problem you encounter so that it might be integrated into FPC's 
test suite which will ease fixing the problem.

Regards,
Sven



More information about the fpc-devel mailing list