[fpc-other] Re: [fpc-pascal] Illogical automatic dereferencing

Florian Klaempfl florian at freepascal.org
Tue Oct 13 20:02:31 CEST 2009


Jonas Maebe schrieb:
> Florian Klaempfl wrote on Tue, 13 Oct 2009:
> 
>> Jonas Maebe schrieb:
>>> I think that "all pointers can be indexed as arrays" can easily cause
>>> accidentantal errors though. I can't find it anymore, but I remember
>>> Pierre once fixed a bug in the compiler sources itself where someone
>>> accidentally used move(pstring_var[1],...) instead of
>>> move(pstring_var^[1],..). That at least was not a case of not
>>> understanding how pointers work, but a simple case of a typo which
>>> couldn't be caught anymore by the compiler due to this extension.
>>
>> What is the alternative?
> 
> Only allowing it for pchar/pwidechar, I guess. 

Then another person pops up and asks why it is allowed only for 
pchar/pwidechar being illogical because this is not orthogonal. Besides 
the fact that I think that the pointer to array work around would be 
really hacking e.g. due to range checking.

> And/or printing a warning 
> in case you are "indexing a pointer" to a type that is an indexed type 
> itself, although I'm not sure how we could make it possible to disable 
> this warning on a case-by-case basis using some kind of explicit syntax 
> saying "yes, I want (pointer+(n-1)*sizeof(pointer))^, not pointer^[n]".




More information about the fpc-other mailing list