Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added EX1 re args in fn decls

...

By using different variable names globally and locally, the compiler forces the developer to be more precise and descriptive with variable names.

Exceptions

DCL01:EX1: A function argument in a function declaration may clash with a variable in a containing scope, provided that when the function is defined, the argument has a name that clashes with no variables in any containing scopes.

Code Block
bgColor#ccccff

extern int name;
void f(char *name);   // declaration: no problem here
// ...
void f(char *arg) {   // definition: no problem, arg doesn't hide name
  // use arg
}

Risk Assessment

Reusing a variable name in a subscope can lead to unintentionally referencing an incorrect variable.

...