[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


> Copy-on-mutate?  What's that?

Copy-on-mutate is a form of lazy evaluation.  It means that:

A = B

doesn't actually copy the values from B into A (A and B are values, not
pointers), instead it just remembers that A is supposed to be equal to
B.  This saves memory and time.  If we later mutate A or B, the copy
occurs.  If you're extra slick, you can put off the copy until a
significant mutation occurs (just accumulate the mutations to apply
later) or until someone actually needs the value.

When big data structures are involved, this is a very handy
optimization, expecially if parts of data structures get lazily copied.
 It also means you never use pointers for efficiency, only for


Morgan McGuire  

Do You Yahoo!?
Send your FREE holiday greetings online!