[fpc-pascal] Illogical automatic dereferencing

Jürgen Hestermann juergen.hestermann at gmx.de
Sat Oct 10 14:32:19 CEST 2009


> This behaviour comes from C syntax.  The array is a pointer, which you
> dereference by using the square brackets.  This is well defined
> syntax, nothing automatic or illogical about it.  The only reason
> pascal programmers make mistakes with this is because they are less
> accustomed to using pointers.

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.

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.





More information about the fpc-pascal mailing list