[fpc-pascal] Constants in generics
ryan at thealchemistguild.com
Tue Nov 6 08:13:01 CET 2018
I implemented a first draft of constants (integers) in generics. My reason was specifically that I wanted a way to add methods to static arrays and generic records is the only way to accomplish this AFAIK.
If I fix this up will it be considered as a patch? I wanted to present the idea first before I spent any more time. Here’s what I has so far (on GitHub).
generic TList<T, U> = record
list: array[0..U-1] of T;
function capacity: integer;
function TList.capacity: integer;
result := U;
nums: specialize TList<integer,10>;
strs: specialize TList<integer,4>;
writeln('sizeof:',sizeof(nums), ' capacity:',nums.capacity);
writeln('sizeof:',sizeof(strs), ' capacity:',strs.capacity);
More information about the fpc-pascal