> I think Delphi basically has the same constraints as C#

Not quite (well maybe back then when they implemented them but C# improved 
since)- also they are subtly implemented differently.

In C# the constraint *class* means "a reference type" - in Delphi it actually 
means it has to be a class.

C# for a long time had similar issues with performing any kind of math in 
generics as Delphi or FPC have - the IComparer and IEqualityComparer interfaces 
where a huge kludge to be able to do generic collections.

Only C# 11 finally fixed this issue via static virtual members on interfaces 
(see 
https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/static-virtual-interface-members)
 so interfaces can be used as constraints and those static members are then 
being used when using operators and alike which enables all kinds of operations 
inside of generic code. A bit similar to C++ concepts (see 
https://en.cppreference.com/w/cpp/language/constraints)
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to