title: Rationalisation of different implementations that are in fact very similar
body: <p>I have several functions like this one :</p>
  <pre><code>TStringListSortCompare = function(List: TStringList; Index1, Index2: Integer): Integer;
  
  procedure TStringList.QuickSort(L, R: Integer; SCompare: TStringListSortCompare);
  begin
    ..
    SCompare(Self, I, P);
    ... 
  end;
  </code></pre>
  <p>or</p>
  <pre><code>TMyStringListSortCompare = function(List: TMyStringList; Index1, Index2: Integer): Integer;
  
  procedure TMyStringList.QuickSort(L, R: Integer; SCompare: TMyStringListSortCompare);
  begin
    ..
    SCompare(Self, I, P);
    ... 
  end;
  </code></pre>
  <p>etc...</p>
  <p>All those quicksort implementations are <strong>exactly the same</strong>. Only the param SCompare is different (ex: <code>TStringListSortCompare = function(List: TStringList; Index1, Index2: Integer): Integer;</code> for the <strong>TStringList</strong> or <code>TMyStringListSortCompare = function(List: TMyStringList; Index1, Index2: Integer): Integer;</code> for the <strong>TMyStringList</strong>. Because of this SCompare params I have plenty of copy/past QuickSort function in my code and If I need to update one I need copy past the modification in all functions (the same in the delphi source code for exemple, look TStringList.quicksort and TwideStringList.quicksort).</p>
  <p>I m looking for a &quot;trick&quot; to make my QuickSort function a global function and make that all <code>TStringList.QuickSort</code>, <code>TMyStringList.QuickSort</code>, etc. will call this global QuickSort function (or inherit).</p>
  <p>I don't think it's possible without sacrificing the simplicity and the speed but I prefer to ask in case I miss something.</p>
  <p>Note: Everything start from reading this bug report : <a href="https://quality.embarcadero.com/browse/RSP-19551" rel="nofollow noreferrer">https://quality.embarcadero.com/browse/RSP-19551</a></p>