Exporting, Importing and Exempting AST Pointers

The astExportastExport function allows you to export particular pointers from one AST context (ยง4.10) to the next outer one, as follows:


\begin{terminalv}
astExport( zoommap );
\end{terminalv}

This would identify the pointer stored in “zoommap” as being required after the end of the current AST context. It causes any pointers nominated in this way to survive the next use of astEndastEnd (but only one such use) unscathed, so that they are available to the next outer context. This facility is not needed often, but is invaluable when the purpose of your astBeginastBegin...astEnd block is basically to generate an ObjectObject pointer. Without this, there is no way of getting that pointer out.

The astImportastImport routine can be used in a similar manner to import a pointer into the current context, so that it is deleted when the current context is closed using astEnd.

Sometimes, you may also want to exempt a pointer from all the effects of AST contexts. You should not need to do this often, but it will prove essential if you ever need to write a library of functions that stores AST pointers as part of its own internal data. Without some form of exemption, the caller of your routines could cause the pointers you have stored to be annulled—thus corrupting your internal data—simply by using astEnd. To avoid this, you should use astExemptastExempt on each pointer that you store, for example:


\begin{terminalv}
astExempt( zoommap );
\end{terminalv}

This will prevent the pointer being affected by any subsequent use of astEnd. Of course, it then becomes your responsibility to annul this pointer (using astAnnulastAnnul) when it is no longer required.