Temporary Variable

In computer programming, a temporary variable is a variable whose purpose is short-lived, usually to hold temporary 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 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. 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). The letters i, j, k and so on are also frequently used for indices, a tradition stemming from early Fortran and mathematics.

Read more about Temporary Variable:  See Also

Famous quotes containing the words temporary and/or variable:

    Managing a tantrum involves nothing less than the formation of character. Even the parent’s capacity to cope well with conflict can improve with this experience. When a parent knows he is right and does not give in for the sake of temporary peace, everybody wins. The parent learns that denying some pleasure does not create a neurotic child and the child learns that she can survive momentary frustration.
    Alicia F. Lieberman (20th century)

    There is not so variable a thing in nature as a lady’s head-dress.
    Joseph Addison (1672–1719)