[fpc-pascal] dynamic array contents and system.move

David Emerson dle3ab at angelbase.com
Wed Apr 28 10:10:38 CEST 2010


Jürgen Hestermann wrote:
> Where are "the usage, internals and purpose of dyn. arrays" documented?

I dunno. But I find them incredibly useful.

they have some quirks, and over the years I've been using dynarrays, I've 
documented these on my own computer -- I even have a dynamic array test program 
that I periodically use to test for dynarray quirks. They're weird and 
unpredictable.

However I'll take all the quirks, for the convenience of being able to call 
setlength (rather than getmem or whatever) -- and moreso, for the even larger 
convenience of automatic freeing of memory -- including automatically freeing 
embedded dynarrays and ansistrings! Those two points alone are, to me, worth 
all the quirks that I have to carefully test and document, and the occasional 
usage error (e.g. the mistake I made that caused me to start this thread). When 
I started using dynamic arrays instead of making calls to getmem/freemem, my 
main project (about 25k LOC now) became substantially simpler and easier to 
maintain.

If you're curious about some of the quirks you can look at my test program, 
which includes some notes I made to myself after running other tests.

http://david9.freepgs.com/fpc/dynamic-arrays.pas

But if you don't like them for all their quirks and impurity, then don't use 
them. I'll be the first to admit that I frequently forget aspects of how they 
work, and have to refer back to my test program.

Cheers,
David




More information about the fpc-pascal mailing list