Assignment of Data Types
Assignment: A basic operation for changing the binding of a value to the data object.
Languages like C, LISP and many more
Assignment also returns a value, which is the data object containing a copy of the value assigned.
In Pascal: dfont>
Assignment(:=): integer1*integer2 -> voidValue of integer2 is copied in integer1 In C Language:
With this action: Set the value contained in data object integer1 to be a copy of the value contained in the data object integer2 and also create and return a new data object integer3, containing a copy of a new value of integer2.
Two Concepts through which we can define assignment
L-Value: Location for an object
R-Value: Content at that location
Using L-Value and R-Value gives a more concise way to describe expression semantics.
Example in case of Integer:
In this copying the value of variable B to variable A. i.e assign to the value L-Value of A the R-Value of B.
In case of pointer
In this A & B are pointers variables. If B is a pointer then B's R-value is the L- value of some other data object. This assignment then means,
"Make the r-value of A refers to the same data object as the r-value of B"
Thus, the assignment A=B means " Assign a copy of the pointer stored in variable B variable A".
Two views of assignment:
Copy pointer: (SNOBOL)
A=B(ptr to value of variable B assigned to variable A)