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

Jürgen Hestermann juergen.hestermann at gmx.de
Tue Apr 27 08:04:24 CEST 2010


>>>> 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.
> It does always mean the same, just like a class instance always means the same. It's just that implicit dereferencing is applied as soon as you try to access an element (again, like with classes).

That means that identifiers for open arrays are always pointers, 'just' with an automatic dereferencing when using square brackets for indexing? Then it should be possible to dereference such identifiers with ^ but it's not. Why? That's the inconcistency I mean: There is no strict logic behind it.

An identifier should always refer to a memory address/location. If the type of the data at that memory location is a pointer then it should be possible to change the expression to the memory address of the data by dereferencing it with ^. But for dynamic arrays (and AnsiStrings and other "modern" structures) this is no longer the case which leads to a lot of confusion. To me it's a design flaw. 

And the help does not tell about the internals (motto: "you don't need to bother about the internals") but if someone follows this advice and it does not work as expected then here in the list all say "don't use it if you don't know about the internals". But then why not tell the internals in the documentation? If I construct a heavily nested data structure with records and pointers to records how do I know that these "special" things like AnsiStrings etc. don't work as all the other types that made the Pascal language so popular. It was clear and easy to understand but now it is no longer.




More information about the fpc-pascal mailing list