[fpc-pascal] Constants in generics

Ryan Joseph ryan at thealchemistguild.com
Wed Apr 12 17:37:22 CEST 2017


> On Apr 12, 2017, at 10:06 PM, noreply at z505.com wrote:
> 
> The only way I can think of extending the functionality of a array is to put it into an old borland object (on the stack) but that may not be what you are looking for. Then you can give the array methods, effectively, possibly reinventing TStringList ;-) and that array can be fixed, dynamic, whatever. But as for generics, no, old borland style objects are not going to be generic - so this email of mine is likely completely and utterly irrelavent to your problem  domain :-)

My problem is I wanted a way to specify a static array size use generics, specifically so I could add methods to use on the array. It’s basically the same talk we’re having now but with static arrays, i.e. I want to add functions and build an API.

type
	generic TList<T,L> = record
		list: array[0..L-1];
		procedure Add (elem: T);
	end;


Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list