Possible Duplicate:
Why is the concept of Marshalling called as such?
Why the conversion between two types is called Marshalling! Wha开发者_开发问答t is the meaning behind Marshal
, why we don't just use the word convert
, is there any difference. Please try to keep a simple english as possible as you can.
Because it's not the same thing.
From Wikipedia:
In computer science, marshalling (sometimes spelled marshaling, similar to serialization) is the process of transforming the memory representation of an object to a data format suitable for storage or transmission. It is typically used when data must be moved between different parts of a computer program or from one program to another.
The word Marshal comes from Millitary terms. Such as to Marshal ones troops and move them somewhere else. From the dictionary:
to arrange in proper order; set out in an orderly manner; arrange clearly:
- to marshal facts; to marshal one's arguments.
- to array, as for battle.
- to usher or lead ceremoniously: Their host marshaled them into the room.
Usually the word "marshalling" is used when you're crossing some sort of boundary. Three obvious use cases:
- Remoting: the RPC data is marshalled to a separate machine (usually)
- AppDomains: an object crossing an AppDomain boundary needs to be marshalled (or it may be marshalled by reference)
- Cross-thread calls: if you use
Control.Invoke
or something similar, that's called marshalling the delegate call to a different thread; so in this case the thread is the boundary
Plain conversions with no such boundaries involved are called just conversions.
For the reasoning behind using the word "marshal" here, see Etienne's answer.
Conversion between two types isn't called marshaling.
Marshaling is moving an object between memory spaces, e.g. different processes, different computers, or different COM apartments. Often serialization is required, to create a portable encoding that doesn't use pointers that are meaningless in the other memory space, and the type changes during serialization, but type conversion and marshaling are orthogonal concepts. Especially, marshalling simple types such as int
and double
(or structures of those) can be done with a simple copy and no conversion.
For a linguistic insight, a marshalling yard is where a railway company re-arranges their trains.
精彩评论