Jump to content

Singleton variable

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Andreas Kaufmann (talk | contribs) at 18:50, 26 April 2008 (Removed category "Programming constructs"; Quick-adding category "Variable (computer programming)" (using HotCat)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer programming a singleton variable is a variable that is referred to only once after it has been declared.

Examples of where a variable might only be referenced once is as a dummy argument in a function call, or when its address is assigned to another variable which subsequently accesses its allocated storage.

This usage pattern sometimes occurs because a mistake has been made, with more than one reference being intended. Some compilers and lint-like tools flag occurrences of singleton variables.

See also

Singleton pattern