[fpc-pascal] Illogical automatic dereferencing

Jürgen Hestermann juergen.hestermann at gmx.de
Tue Oct 13 18:04:49 CEST 2009


> When messing with pointers you've to know what to write because pointers
> allow unlimited access to internal data structures. 

That's not the point. It is very easy to use pointers if they behave 
like this but not if they are used as if they are arrays. I need a fixed 
and unambiguous syntax for

1.) The address of the pointer (@p)
2.) The pointer (p)
3.) The data the pointer is pointing to (p^)

What of these 3 possibilities do I have if I use the identifier 
"DynamicArray"? You can't say it in general because it depends on the 
context.

> Sorry, but I can't
> help you if you guess wrong while playing with dangerous stuff (and the
> original poster did so: using move is a dangerous operation) instead of
> reading the manual.

Again that's not the point. The original poster was aware of what move 
does but was not sure what to write when meaning the array (not the 
pointer). The general rule that an identifier always has a (fixed) type 
was no longer valid.

If the syntax was unambigous there would be no need to guess. Why should 
I use the first element of an array when I want to specify the whole 
array? If I have a fixed array I don't do that either. I am forced to do 
illogical things because the syntax is no longer logical.

> They are strict. However, if one does not understand the logic, it looks
> indeed like magic. 

That's the point: There *is* no logic! At least you have to give several 
  other contraints which makes it unnecessary complicated. The 
"DynamicArray" is the array if you index it with square brackets and it 
is the array if you feed it to other routines but it suddenly turns into 
a pointer if you use it with move.




More information about the fpc-pascal mailing list