[fpc-pascal] How to inline CompareFunc to Sort method in generic abstract class

Hairy Pixels genericptr at gmail.com
Sun Nov 20 02:02:48 CET 2022

> On Nov 20, 2022, at 4:26 AM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> // this kind of constraint that uses T does not work yet
>   generic TList<T; Comparer: specialize TComparer<T>> = class
>     procedure Sort;
>   end;

Does this mean the generic param “Comparer” has a constraint which is "specialize TComparer<T>”? I’ve not ever considered this before but I think it solvers the problem where I suggested you could use something like traits. What is the challenge involved in implemented that so that it hasn’t been done yet? Just curious. :)

And related since it comes to mind now, what is the reason generics inside of generics (like a generic method inside a generic class) are not supported and what challenges are involved? 

Seems like generics are maybe lacking some ability of recursion or something…

Ryan Joseph

More information about the fpc-pascal mailing list