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

Jonas Maebe jonas.maebe at elis.ugent.be
Wed Apr 28 10:48:26 CEST 2010


On 28 Apr 2010, at 08:05, Jürgen Hestermann wrote:

> I am not sure whether this now cast in stone forever. Errors *can*  
> be corrected sometimes. ;-)


The behaviour of dynamic arrays will not be changed. At best, one day  
we may add GPC-compatible array schema types (see http://www.gnu-pascal.de/gpc/Schema-Types.html 
, the part under "As a GNU Pascal extension, the above can also be  
written as"). These don't hide anything.

> A simple solution would be to use the address the pointer is  
> pointing to (address of first element) for fillchar/move too.

It would break code like this:

type
   tbytedynarr = array of byte;
var
   a: array of tbytedynarr;
begin
   setlength(a,10);
   { initialise all dynamic array elements of a}
   ...
   { now delete one of these elements }
   finalise(a[4]);
   { and compact the array }
   move(a[3],a[4],(length(a)-3)*sizeof(a[0]));
end.

With your change, move() would operate on the contents of a[3]  
tbytedynarr instead of on the contents of "a" itself.



Jonas


More information about the fpc-pascal mailing list