temporary_variable
Snippet from Wikipedia: Temporary variable

In computer programming, a temporary variable is a variable with short lifetime, usually to hold data that will soon be discarded, or before it can be placed at a more permanent memory location. Because it is short-lived, it is usually declared as a local variable, i.e., a variable with local scope. There is no formal definition of what makes a variable temporary, but it is an often-used term in programming.

A typical example would be that of swapping the contents of two variables. Temporary variables, along with XOR swaps and arithmetic operators, are one of three main ways to exchange the contents of two variables. To swap the contents of variables "a" and "b" one would typically use a temporary variable temp as follows, so as to preserve the data from a as it is being overwritten by b:

 temp := a
 a := b
 b := temp

Temporary variables are usually named with identifiers that abbreviate the word temporary, such as temp, tmp or simply t, or with common metasyntactic variable names, the most common of which are foo, bar, baz (see also foobar).


Computer hardware is designed to exploit the behaviour of temporary data: a cache or register file may contain temporaries internally to a microprocessor, such that they never need to be committed to main memory (hence consuming no external memory bandwidth).

Variables: Python Variable, Variable (computer science), Unassigned Variables, Variability, Mutable-Mutability, Immutable-Immutability, Constant-Constancy, Named object, Variable Declaration, Variable Definition, Control Variable (Programming), Non-Local Variable, Temporary Variable, Variable Interpolation, Scalar (Mathematics), Variable (Mathematics), Variable Topics. (navbar_variables - see also navbar_math, navbar_programming)


© 1994 - 2024 Cloud Monk Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


temporary_variable.txt · Last modified: 2024/05/01 04:41 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki