Variable/Name

From Jonathan Gardner's Tech Wiki
Jump to: navigation, search

Different languages have different naming conventions for variables. Of note:

  • C and related languages tend to use [_a-zA-Z][_a-zA-Z0-9]*
  • Python is the same as C except it allows unicode letters.
  • Lisp-like languages allow a much broader range of variable names, including most symbols.

Regardless of what the language allows, there is generally a convention on what names mean.

  • Some programming styles include information about the variable type in its name.
  • Some programming styles name certain kinds of variables differently than others, especially depending on scope. (ALL_CAPS for global config, StudlyCaps for class names, etc...)
  • Some programming styles reserve certain keywords for certain kinds of variables. (has_X, is_X, x?, etc...)