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

Jonas Maebe jonas.maebe at elis.ugent.be
Sun Apr 25 19:07:18 CEST 2010


On 25 Apr 2010, at 18:24, Jürgen Hestermann wrote:

>>> But currently move *does* handle dynamic arrays differently than other procedures.
>> It handles it exactly the same as any other function/procedure that takes a untyped/formal "var" parameter. Formal var parameters always take on the address of whatever you pass.
> 
> That's not true!

Well, it is.

> There is a lot of ambigouity with dynamic arrays.

There certainly is if you expect them to work like regular arrays. They are a quite different datatype.

> Although an underlying pointer is used internally you use it as if it was the array this pointer is pointing to in your code. If you first have a static array "MyArray" then convert it to a dynamic array you don't have to change your code (except if you use fillchar and/or move).

Or any other routine that takes an untyped var (or out, or const) parameter. Or if you assign one array to another and modify elements (assigning dynamic arrays creates shallow copies, and unlike with ansistrings these are not made unique when you change individual elements). Dynamic arrays are different from regular arrays in several respects.

>> fillchar() and move() are equivalent to direct assembly level programming as far as the abstraction level is concerned because they ignore all type info. The fact that they ignore all type info is a mess.
> 
> It's true that it ignores all *type* info.

Type info is quite important when type-deendent implicit dereferencing enters the picture.

> Still there was no ambigouity about the starting address of a variable you give as parameter until dynamic arrays were introduced (including AnsiStrings).

And classes. And interfaces (although these don't really point to any data, other than internal stuff).


Jonas

PS: could you correct the clock of your system? Several of your replies have time stamps that predate the mails your are replying to (not this one, but others).


More information about the fpc-pascal mailing list