请输入您要查询的百科知识:

 

词条 Temporary variable
释义

  1. See also

{{Unreferenced|date=December 2009}}

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

See also

  • Temporary folder
  • Temporary file
  • Temporary filesystem
{{DEFAULTSORT:Temporary Variable}}

1 : Variable (computer science)

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/28 19:27:31