Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: Expressions Up: Values, Types, and Constants Previous: Constant Values


Copy On Write

This section really describes an implementational detail whose entire purpose is to prevent you from having to worry about references or the expense of copying large values. Glish values are implemented using copy-on-write techniques. What this means is that values are not copied until absolutly necessary. In the case of something like:
    a := 1:1e7
    b := a
a and b, internal to Glish, share the same underlying storage. They will share the same storage until one of these values is modified so that semantically they can no longer share the storage. So, if something like:
    a[1] := 90
is done, it means a copy will have to be made. However, sometimes a copy may never have to be made. For instance, with the return value of a function a copy need not be made because the function never modifies the return value after it returns. In passing parameters, if the function does not modify one of the val parameters a copy is not made.

So while you should not have to worry about the implementation of the underlying values in Glish, understanding that copy-on-write is used to store values explains the delayed copying cost and may provide some peace of mind.


next up previous contents index
Next: Expressions Up: Values, Types, and Constants Previous: Constant Values   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15