List of forbidden variable names
Posted: Wed Feb 24, 2010 12:28 pm
Hi,
Bad choices of variable names are sometimes harmful to the readability and portability of the code. The last one in date was the naming of a constant using the word 'const', which is also a C keyword. It caused the IBM cpp to replace it with an empty string and ended-up of course in xlf complaining about a syntax error.
I would thus like to start a list with the following:
I don't feel it's too constraining, but I'd like to know what you think about it.
In any case, feel free to extend the list.
Once it is comprehensive enough, there will be a corresponding test in the abirules series.
Bad choices of variable names are sometimes harmful to the readability and portability of the code. The last one in date was the naming of a constant using the word 'const', which is also a C keyword. It caused the IBM cpp to replace it with an empty string and ended-up of course in xlf complaining about a syntax error.
I would thus like to start a list with the following:
- ban the word 'option' of allowed variable names, as it does not provide any information on what the variable does;
- ban French variable names;
- ban any keyword belonging to the C language or interpreted as an instruction by the C preprocessor;
- enforce variable names to be lower-case or mixed-case, while CPP macros should be upper-case only.
I don't feel it's too constraining, but I'd like to know what you think about it.
In any case, feel free to extend the list.
