<div dir="auto"><div><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Benito van der Zander via fpc-devel <<a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>> schrieb am Mo., 8. Sep. 2025, 00:40:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>

  
    
  
  <div>
    <div id="m_7817233428042140091smartTemplate4-template">Hi,<br>
      <br>
      <blockquote type="cite">
        <div dir="auto">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. </div>
        <div dir="auto"><br>
        </div>
      </blockquote>
      <br>
      This calls for a space optimizer that removes unnecessary
      specializations</div>
    <div><br>
    </div>
    <div><br>
      <p>3 optimizations could one have:<br>
      </p>
      * If the project already has a specialization with the types in
      any unit, then it will not be generated again<br>
    </div>
    <div><br>
    </div>
    <div>* 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) <br></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">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. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
    </div>
    <div><br>
    </div>
    <div>* a semantic analysis that determines whether the
      specialization is actually necessary and then does not generate
      anything new if it is not. </div>
    <div>  (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.  )</div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Detecting such is massively complicated. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>