[fpc-pascal] Illogical automatic dereferencing
Jürgen Hestermann
juergen.hestermann at gmx.de
Sat Oct 10 17:46:16 CEST 2009
> 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. How else do you
> think it works?
just look at:
type ArrayType = array[1..10] of char;
var X : ArrayType;
PX : ^ArrayType
What is the difference between X and PX?
X is an array of char which can be accessed directly. The identifier X
means the address in memory where the array elements 1..10 are stored.
The address of X (@X) is the address of the array (first element).
XP is just a pointer to such a structure. It's not the array itself. The
address of XP (@XP) is the address of the pointer, not the array.
Sizeof(X) is 10 bytes.
Sizeof(PX) is 4 bytes.
Still you can use X[1] and PX[1]. That's illogical.
> No, it's not weakened by C-style all of a sudden, it's _always_ been
> like this.
It has never been like this (in Pascal). That's C-style.
More information about the fpc-pascal
mailing list