[fpc-pascal] Illogical automatic dereferencing

Henry Vermaak henry.vermaak at gmail.com
Sat Oct 10 14:53:40 CEST 2009


2009/10/10 Jürgen Hestermann <juergen.hestermann at gmx.de>:
>
> It is illogical that I am able to enumerate a pointer as if it was an array.
> So the brackets do the dereferencing automatically. When I write X[1] it
> assumes I meant X^[1]. To the user it behaves the same as if X was an array
> instead of a pointer to an array. There is no difference in syntax which is
> wrong IMO. It's not wonder that many users think it *is* an array.

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?  Can you explain what would x[1] mean if it isn't
dereferenced?

>
> That's the same as if I could use square brackets for an integer and the
> compiler assumes I meant to pick up one of the bytes. Strict type checking
> was a fundamental goal of Pascal but is has now been weakended by C-style
> creaping into it. If you are forced to use the first element of an array in
> situatons where you wanted to specify the whole array it is illogical. And
> it's not that pascal programmers are less accustomed to pointers, but they
> are less accustomed to obscure compiler magic. It has become fashionable to
> *hide* such things ("you don't need to know the details") and the syntax
> doesn't tell the users either which provokes such mistakes.

No, it's not weakened by C-style all of a sudden, it's _always_ been
like this.  As I've been trying to explain to you, there's no "obscure
compiler magic", if you put the brackets there, the compiler
dereferences.

Henry



More information about the fpc-pascal mailing list