[fpc-pascal] Illogical automatic dereferencing
Mattias Gärtner
nc-gaertnma at netcologne.de
Tue Oct 13 14:26:36 CEST 2009
Zitat von Florian Klaempfl <florian at freepascal.org>:
> Jürgen Hestermann schrieb:
>>
>> Yes, but you cannot avoid it, if you work with dynamic arrays. You are
>> not even told that it's a pointer. That's just the problem.
Same for classes and strings. Classes are pointers and I'm happy that
I can write A.B instead of A^.B.
About pointer arithmetic:
IMO memory is an array. So for me it is quite natural that P^ and P[0]
are the same. I think this is a great feature of FPC, which I don't
want to miss. It's simple, unambiguous and readable - like pascal.
The only disturbing is the automatic dereferencing of pointer to
record/object in Delphi mode, where you can use PtrRect^.Left and
PtrRect.Left.
But that only works in delphi mode, which I avoid.
> The problem is that one is playing with stuff he doesn't understand.
> Explict use of pointers is always dangerous and one should really know
> what he does especially on object pascal dyn. arrays which are much more
> than a simply pointer to the data else one wrecks anyways havoc.
Great power comes with great responsibility.
Mattias
More information about the fpc-pascal
mailing list