赛派号

农哈哈小麦最新播种机新款 Temporary variable

This article does not cite any sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: "Temporary variable" – news · newspapers · books · scholar · JSTOR (December 2009) (Learn how and when to remove this message)

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 behiour 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[edit] Temporary folder Temporary file Temporary filesystem

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至lsinopec@gmail.com举报,一经查实,本站将立刻删除。

上一篇 没有了

下一篇没有了