fbpx
Wikipedia

Value (computer science)

In computer science and software programming, a value is the representation of some entity that can be manipulated by a program. The members of a type are the values of that type.[1]

The "value of a variable" is given by the corresponding mapping in the environment.[2] In languages with assignable variables, it becomes necessary to distinguish between the r-value (or contents) and the l-value (or location) of a variable.[3]

In declarative (high-level) languages, values have to be referentially transparent. This means that the resulting value is independent of the location of the expression needed to compute the value. Only the contents of the location (the bits, whether they are 1 or 0) and their interpretation are significant.[citation needed]

Value category edit

Despite its name, in the C++ language standards this terminology is used to categorize expressions, not values.[4]: 8.2.1 

Assignment: l-values and r-values edit

Some languages use the idea of l-values and r-values, deriving from the typical mode of evaluation on the left and right-hand side of an assignment statement. An l-value refers to an object that persists beyond a single expression. An r-value is a temporary value that does not persist beyond the expression that uses it.[5]

The notion of l-values and r-values was introduced by Combined Programming Language (CPL). The notions in an expression of r-value, l-value, and r-value/l-value are analogous to the parameter modes of input parameter (has a value), output parameter (can be assigned), and input/output parameter (has a value and can be assigned), though the technical details differ between contexts and languages.

R-values and addresses edit

In many languages, notably the C family, l-values have storage addresses that are programmatically accessible to the running program (e.g., via some address-of operator like "&" in C/C++), meaning that they are variables or de-referenced references to a certain memory location. R-values can be l-values (see below) or non-l-values—a term only used to distinguish from l-values. Consider the C expression 4 + 9. When executed, the computer generates an integer value of 13, but because the program has not explicitly designated where in the computer this 13 is stored, the expression is a non l-value. On the other hand, if a C program declares a variable x and assigns the value of 13 to x, then the expression x has a value of 13 and is an l-value.

In C, the term l-value originally meant something that could be assigned to (hence the name, indicating it is on the left side of the assignment operator), but since the reserved word const (constant) was added to the language, the term is now 'modifiable l-value'. In C++11 a special semantic-glyph && exists ( not to be confused with the && operator used for logical operations ), to denote the use/access of the expression's address for the compiler only; i.e., the address cannot be retrieved using the address-of & operator during the run-time of the program (see the use of move semantics). The addition of move semantics complicated the value classification taxonomy by adding to it the concept of an xvalue(expiring value) which refers to an object near the end of its lifetime whose resources can be reused (typically by moving them). This also lead to the creation of the categories glvalue (generalized lvalue) which are lvalues and xvalues and prvalues (pure rvalues) which are rvalues that are not xvalues.[6]

This type of reference can be applied to all r-values including non-l-values as well as l-values. Some processors provide one or more instructions which take an immediate value, sometimes referred to as "immediate" for short. An immediate value is stored as part of the instruction which employs it, usually to load into, add to, or subtract from, a register. The other parts of the instruction are the opcode, and destination. The latter may be implicit. (A non-immediate value may reside in a register, or be stored elsewhere in memory, requiring the instruction to contain a direct or indirect address [e.g., index register address] to the value.)

The l-value expression designates (refers to) an object. A non-modifiable l-value is addressable, but not assignable. A modifiable l-value allows the designated object to be changed as well as examined. An r-value is any expression, a non-l-value is any expression that is not an l-value. One example is an "immediate value" (see above) and consequently not addressable.

In assembly language edit

A value can be virtually any kind of data by a given data type, for instance a string, a digit, a single letter.

Processors often support more than one size of immediate data, e.g. 8 or 16 bit, employing a unique opcode and mnemonic for each instruction variant. If a programmer supplies a data value that will not fit, the assembler issues an "Out of range" error message. Most assemblers allow an immediate value to be expressed as ASCII, decimal, hexadecimal, octal, or binary data. Thus, the ASCII character 'A' is the same as 65 or 0x41. The byte order of strings may differ between processors, depending on the assembler and computer architecture.

Notes edit

  1. ^ Mitchell 1996, p. 9.
  2. ^ Aho, Alfred V.; Lam, Monica S.; Sethi, Ravi; Ullman, Jeffrey D. (1986). Compilers: Principles, Techniques, and Tools. Addison-Wesley Publishing Company. ISBN 0-201-10088-6.
  3. ^ Mitchell 1996, pp. 389–390.
  4. ^ "ISO/IEC 14882:2017 Programming languages — C++". 2017.
  5. ^ "Lvalues and Rvalues (Visual C++)". Microsoft Developer Network. Retrieved 3 September 2016.
  6. ^ William M. Miller. "A Taxonomy of Expression Value Categories" (PDF).

References edit

External links edit

  • Value Object
  • Transfer Object Pattern

value, computer, science, this, article, needs, additional, citations, verification, please, help, improve, this, article, adding, citations, reliable, sources, unsourced, material, challenged, removed, find, sources, value, computer, science, news, newspapers. This article needs additional citations for verification Please help improve this article by adding citations to reliable sources Unsourced material may be challenged and removed Find sources Value computer science news newspapers books scholar JSTOR August 2009 Learn how and when to remove this message In computer science and software programming a value is the representation of some entity that can be manipulated by a program The members of a type are the values of that type 1 The value of a variable is given by the corresponding mapping in the environment 2 In languages with assignable variables it becomes necessary to distinguish between the r value or contents and the l value or location of a variable 3 In declarative high level languages values have to be referentially transparent This means that the resulting value is independent of the location of the expression needed to compute the value Only the contents of the location the bits whether they are 1 or 0 and their interpretation are significant citation needed Contents 1 Value category 1 1 Assignment l values and r values 1 2 R values and addresses 2 In assembly language 3 Notes 4 References 5 External linksValue category editDespite its name in the C language standards this terminology is used to categorize expressions not values 4 8 2 1 Assignment l values and r values edit Some languages use the idea of l values and r values deriving from the typical mode of evaluation on the left and right hand side of an assignment statement An l value refers to an object that persists beyond a single expression An r value is a temporary value that does not persist beyond the expression that uses it 5 The notion of l values and r values was introduced by Combined Programming Language CPL The notions in an expression of r value l value and r value l value are analogous to the parameter modes of input parameter has a value output parameter can be assigned and input output parameter has a value and can be assigned though the technical details differ between contexts and languages R values and addresses edit In many languages notably the C family l values have storage addresses that are programmatically accessible to the running program e g via some address of operator like amp in C C meaning that they are variables or de referenced references to a certain memory location R values can be l values see below or non l values a term only used to distinguish from l values Consider the C expression 4 9 When executed the computer generates an integer value of 13 but because the program has not explicitly designated where in the computer this 13 is stored the expression is a non l value On the other hand if a C program declares a variable x and assigns the value of 13 to x then the expression x has a value of 13 and is an l value In C the term l value originally meant something that could be assigned to hence the name indicating it is on the left side of the assignment operator but since the reserved word const constant was added to the language the term is now modifiable l value In C 11 a special semantic glyph amp amp exists not to be confused with the a href Short circuit evaluation html Support in common programming languages title Short circuit evaluation amp amp a operator used for logical operations to denote the use access of the expression s address for thecompileronly i e the address cannot be retrieved using the address of amp operator during the run time of the program see the use of move semantics The addition of move semantics complicated the value classification taxonomy by adding to it the concept of an xvalue expiring value which refers to an object near the end of its lifetime whose resources can be reused typically by moving them This also lead to the creation of the categories glvalue generalized lvalue which are lvalues and xvalues and prvalues pure rvalues which are rvalues that are not xvalues 6 This type of reference can be applied to all r values including non l values as well as l values Some processors provide one or more instructions which take an immediate value sometimes referred to as immediate for short An immediate value is stored as part of the instruction which employs it usually to load into add to or subtract from a register The other parts of the instruction are the opcode and destination The latter may be implicit A non immediate value may reside in a register or be stored elsewhere in memory requiring the instruction to contain a direct or indirect address e g index register address to the value The l value expression designates refers to an object A non modifiable l value is addressable but not assignable A modifiable l value allows the designated object to be changed as well as examined An r value is any expression a non l value is any expression that is not an l value One example is an immediate value see above and consequently not addressable In assembly language editA value can be virtually any kind of data by a given data type for instance a string a digit a single letter Processors often support more than one size of immediate data e g 8 or 16 bit employing a unique opcode and mnemonic for each instruction variant If a programmer supplies a data value that will not fit the assembler issues an Out of range error message Most assemblers allow an immediate value to be expressed as ASCII decimal hexadecimal octal or binary data Thus the ASCII character A is the same as 65 or 0x41 The byte order of strings may differ between processors depending on the assembler and computer architecture Notes edit Mitchell 1996 p 9 Aho Alfred V Lam Monica S Sethi Ravi Ullman Jeffrey D 1986 Compilers Principles Techniques and Tools Addison Wesley Publishing Company ISBN 0 201 10088 6 Mitchell 1996 pp 389 390 ISO IEC 14882 2017 Programming languages C 2017 Lvalues and Rvalues Visual C Microsoft Developer Network Retrieved 3 September 2016 William M Miller A Taxonomy of Expression Value Categories PDF References editMitchell John C 1996 Foundations for Programming Languages The MIT Press ISBN 0 262 13321 0 Strachey Christopher 2000 Fundamental Concepts in Programming Languages Higher Order and Symbolic Computation 13 11 49 doi 10 1023 A 1010000313106 S2CID 14124601 External links editValue Object Transfer Object Pattern Retrieved from https en wikipedia org w index php title Value computer science amp oldid 1218003322, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.