On Tue, Dec 17, 2002 at 02:47:11PM -0500, Matt Graham wrote: > David Eyler wrote: > > Thanks for all the help. It turns out that this point from Matthew, > > > > "By shallow I mean it copies the data exactly (it copies the pointers > > inside the structure, not the data the pointers point to.)" > > > > was my underlying problem, not the difference between the dereferencing copy > > operation and MemMove. > > sorry, could someone explain this to me. I'm trying to understand this > but it sounds like you're saying that MemMove() would copy the data that > the pointers _inside the structure_ point to? Am I understanding this > right? this seems pretty unlikely. can someone explain the difference > between the two a little further including the difference between a > shallow copy and a deep(?) copy?
A deep copy is a "recursive" copy of a data-structure. In other words is is a copy that descends down the references (pointers in C) contained in the original structure, performing a deep copy of the referenced objects too. Conversely a shallow copy is a "first-level" copy: an exact copy of the memory representation of the given data structure (note that a deep copy will produce *different* objects, while a shallow copy will give exactly identical objects, from a memory representation point of view). In C it is not possible to perform a deep copy in the general case, because C doesn't support data structure introspection at run-time. Languages like Objective C, Smalltalk, LISP, Python, ... giving access at run-time to the structure of objects, can provide both types of copy. Answering to your original question, MemMove() performs a shallow copy, exactly like the assignment operator. Cheers, Marco -- ======================================================================== Marco Pantaleoni [EMAIL PROTECTED] Padova, Italy [EMAIL PROTECTED] elastiC language developer http://www.elasticworld.org -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
