*** Welcome to piglix ***

Value type


In computer science, the term value type is commonly used to refer to one of two kinds of data types: types of values or types of objects with deep copy semantics.

Elements of Programming defines a value to be a sequence of bits, called datum, together with its interpretation. A value type, then, is a correspondence between a set of data and a set of abstract or concrete entities sharing characteristic attributes. The set of entities is sometimes called a species. For example, a value type—call it small_int_value— can establish the correspondence between a sequence of 16 bits and integers values from −32,768 to +32,767 through a two's complement representation.

Value types do not include constraints on how their values are stored. E.g., the type small_int_value in the example above does not determine byte order, alignment, or even the number of 8-bit bytes used to store the 16 bits of the value type's representation. Since the values underpinning value types are not stored, value types also do not include a notion of mutation. A type that does determine constraints for storage in random-access memory is often called an object type.

Pure functional programming languages do not model state and their types are therefore value types in the sense described here.

In contrast, imperative programming languages require a notion of object type. Imperative programming languages also deal with values, but their type systems often do not distinguish the types of values from the types of objects. Instead, the context of an expression determines whether the storage characteristics associated with an object type plays a role or not. For example, in C and C++, expressions are treated as l-values or r-values—the latter can be thought of as having value types.


...
Wikipedia

...