[fpc-devel] if-then-else expression

Sven Barth pascaldragon at googlemail.com
Mon Sep 8 14:11:50 CEST 2025


Benito van der Zander via fpc-devel <fpc-devel at lists.freepascal.org>
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

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20250908/25ba9aa4/attachment.htm>


More information about the fpc-devel mailing list