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

Jürgen Hestermann juergen.hestermann at gmx.de
Sun Apr 25 19:32:01 CEST 2010


>>>> 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.

In the help for fillchar it says:

"Fillchar fills the memory starting at X with Count  bytes or characters with value equal to Value."

So what should a user think if he uses the identifier "MyArray" of a dynamic array as parameter? How should he know that *in this case* "MyArray" is taken as the pointer to the array while in all other cases (indexing etc.) it is meant to be the array itself?

>> 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.

At least it should always mean the same independent from context.

>> 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. 

In all these cases the meaning of the identifier of a variable should stay the same. Only handling is different.





More information about the fpc-pascal mailing list