[fpc-pascal] FPC's generics implementation

Jani Mátyás jzombi at gmail.com
Tue Aug 25 14:17:39 CEST 2015


Thank you for the answers!

> > The FPC wiki states that the ppu file stores all the tokens for the
> generic classes. Browsing the source of compiler/symdef.pas (r31298) also
> gave me this impression. Does it mean that a recompilation occurs for every
> specialization?
> Not for every specialization. If a specialization for the same generic
> with the same types already exists that one will be used. This also works
> across units.
Great, then my third question is not important.

> There have been some ideas (again, regarding the wiki) to store the parse
> tree instead of the source code (or tokens) in the ppu. I guess that would
> made the specializations quicker. What were the reasons against it?
> Ease of implementation/maintainability.
> For the node tree approach the tree would need to be walked and all
> accesses to variables of the generic parameter types would need to be
> adjusted. This would need adjustments if new node types are added or node
> types are extended. However for the token stream approach all this is
> handled by existing parser code, so once the parser supports something it's
> immediately supported by generics as well (corner cases of respecting
> generic types aside).
 I see your point, thanks.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150825/8308e352/attachment.html>

More information about the fpc-pascal mailing list