
7.5 The Store structure
Explicit machine pointers must therefore be treated with care. For example, there is a facility for providing 'local' pointers, which are represented as a local offset from the base address of the store. The use of small indices here means that conventional array indexing can be used directly from ML. Of course, this facility also requires the ability to convert between local indices and actual machine addresses.
The advantage of using 'local' pointers is that they remain invariant under expansion of the store. However, their disadvantage is that they are meaningless if used out of context. Hence, local pointers must not be passed into foreign code -- they must first be converted into machine addresses. The FI provides tools for performing these conversions.
One way of avoiding these difficulties is to work with stores that cannot be expanded, but which have sufficient static space allocated to start with. In this case, machine addresses cannot be invalidated due to store expansion and so can be passed to foreign code with impunity.

Generated with Harlequin WebMaker