[fpc-devel] Local variable names and colision with attributes/properties names

Michael Van Canneyt michael at freepascal.org
Thu Sep 27 19:26:31 CEST 2012



On Thu, 27 Sep 2012, Marcos Douglas wrote:

>>> However we can use "poor names" -- very difficult to happen a
>>> collision -- to represent a variable like A, J, D... but I do not
>>> think this is a good practice and you?
>>
>>
>> I do think this is good practice. I will seldom use variable names of more
>> than 2 characters.
>
> So, just a letter "J" tell us everything we need about the variable?
> IMHO this contradicts the spirit of Pascal, a beautiful and readable
> language, but I guess I will lost this discussion.

I do not think it is that black and white :)

I agree that parameter names and global constants should have clear names,
(so code completion is actually useful) but for local variables, I do not 
think this is necessary.

Do you think this

   For MyVeryClearName := StartValue to EndValue do
     MyVerLargeArray[MyVeryClearName]:=MyVeryClearName;

Is better than this:

   For I:=S to E do
     A[i]:=I;

I hope not :-)

And it's not about the size of variable names. 
It's just about avoiding duplicate names which can lead to confusion.

Michael.



More information about the fpc-devel mailing list