[fpc-pascal] Illogical automatic dereferencing

Henry Vermaak henry.vermaak at gmail.com
Sat Oct 10 20:15:09 CEST 2009


2009/10/10 "Vinzent Höfler" <JeLlyFish.software at gmx.net>:
> Henry Vermaak <henry.vermaak at gmail.com>
>
>> I can't understand what you are trying to say.  An array is a pointer
>> to where the elements of the array resides in memory.
>
> No, not in Pascal. In Pascal an array is a variable just like any other: A name for some memory area where values can be stored.
>
>> How else do you think it works?
>
> Just like "a : integer" -> reserve the needed number of bytes and let the programmer access the associated memory via the identifier "a".
>
>> Can you explain what would x[1] mean if it isn't dereferenced?
>
> Access the memory at address of "x + 1 * (size of element)".
>
> Just like you do
>
> array4 : record a1, a2, a3, a4 end;
>
> and access the record members respectively. It's a static address, known at compile time. No dereferencing.
>
>> No, it's not weakened by C-style all of a sudden, it's _always_ been
>> like this.
>
> No. Your confusing arrays and pointers. Or maybe, you're confusing Pascal and C.

Thanks for the explanation, I was under the impression that arrays in
Pascal were similar to C.  How do you explain the "automatic"
dereferencing with a pointer to an array that Jürgen is talking about?

Henry



More information about the fpc-pascal mailing list