A dynamic array of records is the wrong structure in this case, because adding elements leads to a reallocation which is really, really expensive.
A list or something is a far better structure to implement such things.
Ok thanks. I'm familiar with ArrayList in Java and this looks pretty similar. I was doing it like this to get familiar with the way dynamic arrays work in fp.
I hadn't got as far as reading about 'advanced records' and wasn't aware that they could have methods - I like that, rather like D's structs. The record/object/class business seems a bit confusing but it seems I could just ignore objects (I mean 'object type' not instances of a class which are what I think of as objects!).
@marcov: Yes, I don't like that 'dangerous' syntax, it's all too easy to omit or misplace a value - the form you suggest with tags is something I've encountered before.
Thanks all for the replies.
P.S. Is there any downside to compiling in Delphi mode? Does standard fp code still work without modification provided I take account of the things specified here
http://www.freepascal.org/docs-html/prog/progse74.html ?
EDIT. Hmm, 'uses glinkedlist' gives me a 'can't find unit' error and I don't see it here:
http://wiki.freepascal.org/Data_Structures,_Containers,_CollectionsActually as I only need to add items on the end a vector will do - and that compiles ok.