[fpc-pascal] Illogical automatic dereferencing

Florian Klaempfl florian at freepascal.org
Mon Oct 12 11:06:56 CEST 2009


Jürgen Hestermann schrieb:
>>> 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.

> because it leaves it
> unclear what data you are operating with.
> Enumerating a pointer makes
> you think that you are enumerating an array. That was the origin of the
> whole threat because someone was not clear about what to use as
> parameter in MOVE. It is no longer logical what a written identifier
> means: A pointer or an array.

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.



More information about the fpc-pascal mailing list