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

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


On 25 Apr 2010, at 17:38, Jürgen Hestermann wrote:

>>> It would be possible to allow this syntax :
>>>  move(data ...
>>> in addition to the current :
>>>  move(data[0] ...
>>> There is no fundamental reason why it wouldn't be possible. 
>> There is: there is no reason why move should be handled differently than other procedures.
> 
> 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.

The confusion comes from the fact that a dynamic array, just like ansi/wide/unicodestrings and a Delphi-style classes/interfaces, is an implicit pointer to the actual data. Hence, if you pass a variable of such type to a formal var parameter, you are passing a pointer to this implicit pointer as the parameter value (rather than a pointer to the actual data).

>> If you mess with move 
> 
> What do you mean with "mess". It's a standard function since decades.

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.


Jonas


More information about the fpc-pascal mailing list