<p>Am 25.08.2015 08:34 schrieb "Jani Mátyás" <<a href="mailto:jzombi@gmail.com">jzombi@gmail.com</a>>:<br>
> 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?</p>
<p>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.</p>
<p>><br>
> 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?</p>
<p>Ease of implementation/maintainability. <br>
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).</p>
<p>> Disabling assignment compatibility of the separate specializations (with same parameter type) might reduce the number of specializations. Were there any specific reasons for enabling it in objpas mode?</p>
<p>On the contrary. /Enabling/ assignment compatibility reduces the number of specializations, because existing specializations can be reused (see above).<br>
Also having specializations be compatible in mode Delphi, but not in other modes would likely lead to the confusion of users as units with different modes can be mixed freely.</p>
<p>Regards,<br>
Sven</p>