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

Aleksa Todorovic alexione at gmail.com
Wed May 5 10:13:12 CEST 2010


On Wed, May 5, 2010 at 07:34, Jürgen Hestermann
<juergen.hestermann at gmx.de> wrote:
>> So why is it a problem, that one is a pointer, and the other not? Because
>> it is easier, or more often overlooked.
>
> The problem is not that one is a pointer (to an array) and the other one is
> the array itself. That would be fine if it is told to the programmer that
> way and if it would be consistent. But then why am I not able to
> derefference this pointer with MyArray^? Why can I use an index on that
> pointer? In these cases it does *not* behave like a pointer but like an
> array. That's what makes it ambiguous.

You do not use index on *pointer* but on *dynamic array* (as already
explained). As of copying/moving array elements, why don't you use
simple for loop for that, because that's what you actually want to do?
I have used dynamic arrays for years, and didn't have these problems,
because, when I want to say "address of the first element", I write
it: "a[low(a)]". I don't *guess* nor I want compiler to *guess*. And
thinking that address of dynamic array variable should be address of
it's first element is plain *guess*. Unfortunately, wrong in this
case.

Move and Fillchar are low-level system functions, and they are
perfectly logical, although little hard to understand :-) Just try to
create dynamic array of dynamic arrays and used those functions on
them, and you will understand.

I, also, agree that FPC is far from simple Pascal language, but that
fact is that FPC team needs to: 1) follow
Borland/Inprise/Embercadero/... in their decisions; 2) try to add new
language features which will give more power to the language; 3)
maintain crossplatform-ness of the compiler (including adding
platform-specific features); 4) keep RTL, FCL and other packages in a
good and usable shape; ... Not really nice environment to mess around
with such low level functions by adding special cases, isn't it? :-)



-- 
Aleksa Todorovic - Lead Programmer
Eipix Entertainment
www eipix com



More information about the fpc-pascal mailing list