Value Types
Explore the concept of value types in D programming, focusing on how variables carry their own values, their memory identity, and the difference between value equality and value identity. Understand how value types like integers and fixed-length arrays behave, and learn to use the address-of operator to inspect memory locations.
We'll cover the following...
Value types are easy to describe: variables of value types carry values. For example, all of the integer and floating point types are values types. Although not immediately obvious, fixed-length arrays are value types as well.
For example, a variable of type int has an integer value:
int speed = 123;
The number of bytes that the variable speed occupies is the size of an int. If we visualize the memory as a ribbon going from left to right, we can imagine the variable living on some part of it:
When variables of value types are copied, they get their ...