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

Marcos Douglas md at delfire.net
Thu Sep 27 19:36:53 CEST 2012

On Thu, Sep 27, 2012 at 2:26 PM, Michael Van Canneyt
<michael at freepascal.org> wrote:
> 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 :)

Maybe grey. Equilibrium.  :)

> 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 :-)

Of course the second is (a little) better.

But, If you permits:
for i := StardValue to EndValue do
  MyArray[i] := i;

Now is more readable. More verbose than the first but less verbose
than second.  ;)

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

You right but:
- prefix increases the size   :P
- variables abbreviated are more easy to programmers do not use the
same names to, objects, primitives variables, etc.

Marcos Douglas

More information about the fpc-devel mailing list