[fpc-pascal] Illogical automatic dereferencing
Aleksa Todorovic
alexione at gmail.com
Sat Oct 10 15:39:00 CEST 2009
Also, it is very important to make distinction between static and
dynamic arrays. For static arrays, compiler knows their exact memory
location at compile time (modulo situations where static array is part
of another structure), but for dynamic arrays, compiler only knows
where in memory is reference (akka pointer) to the contents of that
array. So, if we wanted to have that distinction on syntax level, we
would have to use X[1] for static arrays and X^[1] for dynamic arrays.
Doesn't sound nice, does it?
On Sat, Oct 10, 2009 at 15:32, Marco van de Voort <marcov at stack.nl> wrote:
> In our previous episode, Henry Vermaak said:
>> >
>> > That link is talking about interchangability, which is not the same as being
>> > the same.
>>
>> Yes, I'm just trying to explain that there's no magic to it,
>> illustrated by some basic pointer arithmetic.
>
> I think there are several bits that mix in this thread:
>
> 1 nearly all types that don't fit in registers are in memory, and you need
> a memory access to reference them. This makes them all
> references/pointers/addresses on assembler level, but not necessary pointers
> on language level.
> 2 The fact that Delphi mandatory skips a ^ when indexing a pointer + array.
> 3 The fact that FPC allows both in objfpc mode. (which means)
> 4 The fact that FPC and Delphi allow pchar to be overindexed.
> 5 The fact that FPC and Delphi 2009+ with {$pointermath on} also allow it
> for other pointer types.
>
> Note that I write this from memory after porting some FPC bits to Delphi
> last week. Most notably the {$pointermath on} (5) and the mandatory aspect
> of (2) might be related.
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
--
Aleksa Todorovic - Lead Programmer
Eipix Entertainment
http://www.eipix.com/
More information about the fpc-pascal
mailing list