I've pushed some updates to the DependentModules branch. Trying to figure out dependencies automatically seemed to be too complicated so now the responsibility has been moved to the caller. That has required some changes to the types of the functions and some new functions. The relevant part of the signature of PolyML.SaveState is now:
type moduleId = WordVector.vector
val saveDependentModule: string * {structs: string list, sigs: string list, functors: string list, onStartup: (unit -> unit) option} * (moduleId * string) list -> moduleId
val saveDependentModuleBasic: string * Universal.universal list * (moduleId * string) list -> moduleId
val saveModule: string * {structs: string list, sigs: string list, functors: string list, onStartup: (unit -> unit) option} -> moduleId
val saveModuleBasic: string * Universal.universal list -> moduleId
val loadModule: string -> moduleId val loadModuleBasic: string -> Universal.universal list * moduleId
val showLoadedModules: unit -> moduleId list val releaseModule: moduleId -> unit val getModuleInfo: string -> moduleId * (moduleId * string) list
The moduleId is the 8 byte signature of the module generated from a combination of a time-stamp and a hash of the contents.
The main difference from the previous version is that saveModule and saveModuleBasic create independent modules without any dependencies. To create a module with dependencies it is necessary to use saveDependentModule or saveDependentModuleBasic. These have an additional argument which is a list of the moduleIds to be included as dependencies. They must be currently loaded or saved in the current session.
The additional string value for each dependency is intended to be used when the module is loaded. When loadModule or loadModuleBasic is called to load a module which has dependencies a check is made to see if the dependency has already been loaded. If it has not the string is used as the argument to a recursive call to loadModule/loadModuleBasic to load the dependency. If the string is the empty string this will not happen and, since the dependency is not loaded and cannot be located the attempt to load the dependent module will fail.
releaseModule has been added and this moves the module from permanent store into local, garbage-collected memory. It does not remove any structures, signatures or functors from the name space but allows for garbage collection if they are redefined. It can be used to get the same effect as loadModule and saveModule previously had.
I'm hoping this will solve most of the outstanding problems and the requirement to specify the dependencies won't cause problems for the ML Basis code. The mechanism essentially provides an alternative to the long-standing saved state system.
David