* * *

Author Topic: Generics and overloading  (Read 1326 times)

ASerge

  • Hero Member
  • *****
  • Posts: 963
Re: Generics and overloading
« Reply #15 on: October 29, 2018, 07:43:02 pm »
Does it evaluate the type at run time and then choose the appropriate function, cause if this is the case it seems very ineffective and I was asking if there is a way to make the compiler select the function at compile time. (as it is possible for operator overloading)
For GetTypeKind, the compiler does all the work itself and the result contains only two functions:
Code: Pascal  [Select]
  1. class function TDoStd.DoIt(a: string): string; static;
  2. begin
  3.   Result := MyFun(a);
  4. end;
and
Code: Pascal  [Select]
  1. class function TDoStd.DoIt(a: Double): Double; static;
  2. begin
  3.   Result := MyFun(a);
  4. end;
You can add -al switch and see the source code in the assembler, or examine the code in the debugger.

heju

  • New member
  • *
  • Posts: 7
Re: Generics and overloading
« Reply #16 on: November 01, 2018, 12:36:45 am »
This is very nice, I like it  :D
I will have a look with the debugger, just for curiosity...
Thanks for your explanations!

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus