World Library  
Flag as Inappropriate
Email this Article

Temporary variable

Article Id: WHEBN0002869262
Reproduction Date:

Title: Temporary variable  
Author: World Heritage Encyclopedia
Language: English
Subject: Copy elision, Return value optimization, Variable (computer science), Euclidean algorithm, Subroutine
Collection: Variable (Computer Science)
Publisher: World Heritage Encyclopedia

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).

See also

This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.