[fpc-devel] generics

Peter Vreman peter at freepascal.org
Thu Apr 28 07:53:06 CEST 2005


> Hi,
>
> I'm trying to add support for generics (templates) to fpc.
>
> Do we want to have a "generics" section (like "interface",
> "implementation") or do we want a special source code type (like "unit",
> "program") in the source code ?
>
> I'm tending to a special source code type "generic unit".
>
> The generic source code file (.pas,.pp) is installed (not the .ppu,.o).
> Then in the 'uses' handler, when not finding a ppu, it reverts to the
> pas file, and then finds that it is a special source code "generic unit"
> or so, so it *doesnt* compile it right now, but 'uses' actually just
> registers the generic classes as 'available for compilation later'.

You only need 1 generic type at once. Why should a complete generic unit
be used? Also using it as a unit is inconsistent with the way that units
are handled and will require a lot of if..then parts in the unit loading
code. And that code is already one of the most complex parts of the
compiler. It is already on a after 2.0 todo list to be rewritten because
of this complexity.







More information about the fpc-devel mailing list