Jump to content

Singleton variable

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by SmackBot (talk | contribs) at 14:43, 17 December 2009 (remove Erik9bot category,outdated, tag and general fixes). 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