Last week a young student ask me if marshalling is the same as casting.
My answer was definetly no. Marshalling is seralization, the way to transform a
memory representation of an objet into bytes in order to be transmitted to a
network whereas casting is related to type convertion / coercion.
Later on, rethinking the question I was thought that marshalling can be seen as a special case of casting. For example the transformation of the memory representation is in xml then one can say that you are “casting” to the type defined by the corresponding xsd grammar of that xml file.
What do you think about this?
Casting doesn’t modify the data type. That is a major distinction. When you marshal something, you are transforming the data into something else.
A simple cast only changes how you are interpreting the object, not what the object is internally.
I agree that the distinction should be clear else unfamiliar people may be confused.