Using generic method as a const or type for another generic method lazarus / 62-General ---------------------------------------------------------------------- Okoba · 2021-08-03 16:12 I want to send a parameter of a generic type to another generic type, the catch is that if I send the method as a parameter it seems FPC can not inline it and it takes much more time to execute. So I thought if there is a way to pass the method as a const or a type to another method but Test3 or Test4 fails. Is there any way? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; {$mode objfpc} type  generic TTest = procedure(A: T);   generic procedure Test1(A: T);  begin  end;   generic procedure Test2(A: T; F: specialize TTest);  var    i: Integer;  begin    for i := 1 to 10000000 do      F(I);  end;   generic procedure Test3>(A: T);  var    i: Integer;  begin    for i := 1 to 10000000 do      F(I);  end;   generic procedure Test4>(A: T);  var    i: Integer;  begin    for i := 1 to 10000000 do      F(I);  end; beginend. ---------------------------------------------------------------------- PascalDragon · 2021-08-04 07:09 Quote from: Okoba on August 03, 2021, 06:12:55 pmI want to send a parameter of a generic type to another generic type, the catch is that if I send the method as a parameter it seems FPC can not inline it and it takes much more time to execute. Method/function pointers can not be inlined, no matter if generic or not. Note: for certain situations the compiler could in theory be extended to optimize this, but this is currently not the case and also won't be the case in general. ---------------------------------------------------------------------- Okoba · 2021-08-04 07:33 I guessed it can be for a constant in generics. It can be useful for proving a custom compare function for search/sort. For now the only way come to mind is to pass the function parameter and in my tests it makes it much slower.