[fpc-pascal] Illogical automatic dereferencing

Jürgen Hestermann juergen.hestermann at gmx.de
Mon Oct 12 12:47:28 CEST 2009


>>>> No, it happens with static arrays,  if you set pia := @ia, ia[x] and
>>>> pia[x] will give you the same result (in delphi mode, at least).
>>> It's simply more readable and a shortcut.
>> It's definitely the opposite: It is *less* readable 
> This is your opinion :) To my experience faking arrays with dyn. size by
> using array declarations with infinite size (else you get in trouble
> with range checking) are much more error prone and unreadable than using
> pointers with an implicit dereference operator as arrays. As soon as you
> start using them like normal arrays (new, high, sizeof, passing them to
> open array parameters, no range checking) you get burned as well, even
> not taking care the extra declarations you need.

What has the one thing to do with the other? It would have been easy to 
introduce dynamic arrays without hiding away its nature from the user.

> E.g. ansi- and widestrings or classes use implicit dereferencing as well
> and they proved to work very well. If someone uses low level operations
> like Move he should know what he does.

That's just the point: Most users are left unclear about the nature of 
data structures and they start doing an trial and error approach 
(changing syntax as long as it is compiled). Then hope it will do what 
they intented. That's exactly C-style! Of course, there are some that 
look under the hood and know about the details and only these people are 
able to avoid such things as memory leaks or pointers pointing to freed 
memory and so on. The others stumble through it praying that it runs and 
as long as 80% procent works they are already satisfied. That's not the 
spirit of Pascal. The language should be clear and predictable from the 
start.



More information about the fpc-pascal mailing list