Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
a := 1:1e7 b := aa 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] := 90is 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.