This commit is contained in:
hsutter 2015-12-28 10:49:07 -08:00
parent c6891262a7
commit 9c2aba298c

View File

@ -7701,15 +7701,28 @@ Check length of local and non-local names. Also take function length into accoun
##### Reason
Such names slow down comprehension and increase the likelihood of error.
Code clarity and readability. Too-similar names slow down comprehension and increase the likelihood of error.
##### Example
##### Example; bad
if (readable(i1 + l1 + ol + o1 + o0 + ol + o1 + I0 + l0)) surprise();
##### Enforcement
##### Example; bad
Do not declare a non-type with the same name as a type in the same scope. This removes the need to disambiguate with a keyword such as `struct` or `enum`. It also removes a source of errors, as `struct X` can implicitly declare `X` if lookup fails.
struct foo { int n; };
struct foo foo(); // BAD, foo is a type already in scope
struct foo x = foo(); // requires disambiguation
##### Exception
Antique header files might declare non-types and types with the same name in the same scope.
##### Enforcement
* Check names against a list of known confusing letter and digit combinations.
* Flag a declaration of a variable, function, or enumerator that hides a class or enumeration declared in the same scope.
Check names against a list of known confusing letter and digit combinations.
### <a name="Res-not-CAPS"></a> ES.9: Avoid `ALL_CAPS` names