Benito van der Zander via fpc-devel <[email protected]>
schrieb am Mo., 8. Sep. 2025, 00:40:

> Hi,
>
> Implicit function specialization would change that, however that would
> mean the generation of a specialized definition each time it is used in a
> different unit and for every type.
>
>
> This calls for a space optimizer that removes unnecessary specializations
>
>
> 3 optimizations could one have:
> * If the project already has a specialization with the types in any unit,
> then it will not be generated again
>
> * If two different specialization create the same assembly, then the
> previous specialization will be reused (bitwise comparison of the code
> after it has been generated)
>

These two are nice and well in theory, but due to units being independent
of each other this can in the end only be handled by the linker.


> * a semantic analysis that determines whether the specialization is
> actually necessary and then does not generate anything new if it is not.
>   (e.g. if a function is generic <T: TObject>, but no properties of T are
> used, but it only cast a result to T (like e.g. a generic TList.get), then
> it can create the function for TObject once and then never again for T.  )
>

Detecting such is massively complicated.

Regards,
Sven

>
_______________________________________________
fpc-devel maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to