To be able to share associated data structures such as symbol tables and dependency graphs, CM maintains an internal registry of all stable libraries that it has encountered during an ongoing interactive session. The CM.Library sub-structure of structure CM provides access to this registry.
structure Library : sig
type lib
val known : unit -> lib list
val descr : lib -> string
val osstring : lib -> string
val dismiss : lib -> unit
val unshare : lib -> unit
end
CM.Library.known, when called, produces a list of currently known stable libraries. Each such library is represented by an element of the abstract data type CM.Library.lib.
CM.Library.descr extracts a string describing the location of the CM description file associated with the given library. The syntax of this string is almost the same as that being used by CM's master-slave protocol (see section 12.1).
CM.Library.osstring produces a string denoting the given library's description file using the underlying operating system's native pathname syntax. In other words, the result of a call of CM.Library.osstring is suitable as an argument to TextIO.openIn.
CM.Library.dismiss is used to remove a stable library from CM's internal registry. Although removing a library from the registry may recover considerable amounts of main memory, doing so also eliminates any chance of sharing the associated data structures with later references to the same library. Therefore, it is not always in the interest of memory-conscious users to use this feature.
While dependency graphs and symbol tables need to be reloaded when a previously dismissed library is referenced again, the sharing of link-time state created by this library is not affected. (Link-time state is independently maintained in a separate data structure. See the discussion of CM.unshare below.)
CM.Library.unshare is used to remove a stable library from CM's internal registry, and--at the same time--to inhibit future sharing with its existing link-time state. Any future references to this library will see newly created state (which will then be properly shared again). ( Warning: This feature is not the preferred way of creating unshared state; use functors for that. However, it can come in handy when two different (and perhaps incompatible) versions of the same library are supposed to coexist--especially if one of the two versions is used by SML/NJ itself. Normally, only programmers working on SML/NJ's compiler are expected to be using this facility.)