singleton variable


singleton variable

(programming)A variable which is only referred to once in apiece of code, probably because of a programming mistake. Tobe useful, a variable must be set and read from, in thatorder. If it is only referred to once then it cannot be bothset and read.

There are various exceptions. C-like assignment operators, e.g. "x += y", read and set x and return its newvalue (they are abbreviations for "x = x+y", etc). Afunction argument may be passed only for the sake ofuniformity or to support future enhancements. A goodcompiler or a syntax checker like lint should reportsingleton variables but also allow specific instances to bemarked as deliberate by the programmer.