Temporary variable

Temporary variable

In computer programming, a temporary variable is a variable whose purpose is short-lived, usually to hold temporarily 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

(See the XOR swap algorithm for swapping without a temporary variable.)A more real example is that of swapping two elements in an array, as it is done in the RC4 algorithm and in sorting algorithms.

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

ee also

*Temporary folder
*Temporary file
*Temporary filesystem


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Temporary file — Temporary files may be created by computer programs for a variety of purposes; principally when a program cannot allocate enough memory for its tasks, when the program is working on data bigger than architecture s address space, or as a primitive …   Wikipedia

  • Temporary — is a term that denotes a finite period of time, with a defined beginning and an end. It is derived from the Latin temporarius of seasonal character, lasting a short time, from tempus (gen. temporis ) time, season. It is the opposite of permanent …   Wikipedia

  • Temporary folder — In computing, a temporary folder or temporary directory is a directory used to hold temporary files. Many operating systems and some software automatically delete the contents of this directory at bootup or at regular intervals.For security… …   Wikipedia

  • Temporary Internet Files — is a directory on Microsoft Windows computer systems. The directory is used by Internet Explorer to cache pages and other multimedia content, such as video and audio files, from websites visited by the user. This allows such websites to load more …   Wikipedia

  • Variable local — Una variable local es, en informática, la variable a la que se le otorga un ámbito local. Tales variables sólo pueden accederse desde la función o bloque de instrucciones en donde se declaran. Las variables locales se contraponen a las variables… …   Wikipedia Español

  • Variable-message sign — Sign over Interstate 94 in Saint Paul, Minnesota, advising of a road blockage during a winter storm …   Wikipedia

  • Temporary star — Star Star (st[aum]r), n. [OE. sterre, AS. steorra; akin to OFries. stera, OS. sterro, D. ster, OHG. sterno, sterro, G. stern, Icel. stjarna, Sw. stjerna, Dan. stierne, Goth. sta[ i]rn[=o], Armor. & Corn. steren, L. stella, Gr. asth r, a stron,… …   The Collaborative International Dictionary of English

  • Variable Darner — Taxobox name = Variable Darner image width = 240x image caption = Aeshna Interrupta regnum = Animalia phylum = Arthropoda classis = Insecta ordo = Odonata familia = Aeshnidae genus = Aeshna species = A. interrupta binomial = Aeshna interrupta… …   Wikipedia

  • Temporary equilibrium method — The temporary equilibrium method has been devised by Alfred Marshall for analyzing economic systems that comprise interdependent variables of different speed.For example: Assume an industry with a certain capacity that produces a certain… …   Wikipedia

  • Variable star — Star Star (st[aum]r), n. [OE. sterre, AS. steorra; akin to OFries. stera, OS. sterro, D. ster, OHG. sterno, sterro, G. stern, Icel. stjarna, Sw. stjerna, Dan. stierne, Goth. sta[ i]rn[=o], Armor. & Corn. steren, L. stella, Gr. asth r, a stron,… …   The Collaborative International Dictionary of English

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”