signature COMPONENT structure Component : COMPONENT
This structure provides components as first-class entities and operations on them. We speak of unevaluated and evaluated components. An unevaluated component is a component which has not yet been linked and applied, that is, its declarations have not been executed. An evaluated component is similar to a package: it has empty import announcements, cannot be applied to produce side-effects, and as such is just a pair of a structure and its (export) signature.
The linking and evaluation of components takes place in component managers.
If the environment variable ALICE_TRACE_COMPONENT is set, then trace messages concerning linking, type-checking and evaluation of components will be logged. If the environment variable is set to the empty string, logging is performed on the standard error output stream. Otherwise, the variable's value is interpreted as a filename opened for logging. If the file already exists, it is overwritten. If it cannot be opened for writing, logging falls back to standard error.
For more background, see the overview of components.
See also: COMPONENT_MANAGER, Sandbox, Compiler, Resolver, Package, Pickle
import structure Component from "x-alice:/lib/system/Component" import signature COMPONENT from "x-alice:/lib/system/COMPONENT-sig"
signature COMPONENT = sig type component type t = component exception Sited exception Corrupt exception NotFound exception Mismatch of {component : Url.t, request : Url.t option, cause : Inf.mismatch} exception Eval of exn exception Internal of exn exception Failure of Url.t * exn val extension : string val defaultResolver : Resolver.t val fromPackage : package -> component functor Create(signature S functor F (CM : COMPONENT_MANAGER) : S) : (val component : component) val load : Url.t -> component val save : string * component -> unit functor MkManager(val resolver : Resolver.t) : COMPONENT_MANAGER end
The type of first-class components.
used by the save operation to indicate that a first-class component contains sited data structures. This exception is not raised directly; it only appears as the cause of an IO.Io exception.
used by the load operation to indicate that the contents of a file did not represent a well-formed pickled component. This exception is never raised directly; it only appears as the cause of an IO.Io exception.
used by the load operation to indicate that a component could not be located. This exception is never raised directly; it only appears as the cause of an IO.Io exception.
indicates a signature mismatch during dynamic linking. component is the URL of the component whose export signature did not meet the requirements of the requestor given by request. A requestor of NONE indicates a request made programmatically. The cause is the mismatch reported by the used signature-checking facility.
indicates that a component raised an exception during initialization, that is, while its declarations were being evaluated. This is never raised directly, but packaged in a Failure exception instead.
indicates that the component manager failed internally with the given exception, either due to a failure to acquire essential runtime components, or because of an internal inconsistency. This is never raised directly, but packaged in a Failure exception instead.
indicates that the loading, evaluation or type checking of a component failed. The URL is that of the component. If loading failed, the exception is an IO.Io exception. If evaluation failed, the exception is an Eval exception. If signature matching failed, the exception is a Mismatch exception.
is the string used on the current platform as extension part to name files containing pickled components. This does not include the period commonly used to separate file names' base and extension parts.
is a resolver initialized by alicerun from the ALICE_LOAD_PREFIX and ALICE_LOAD_SUFFIX environment variables. defaultResolver is a memoizing resolver with the name "load". It is the resolver used by load.
creates an evaluated component with the module and signature from package p.
returns a component (as val component of the resulting structure) whose body is given by the functor body X, and which has export signature S. The component manager CM can be used to import other components inside the body. If the manager is not required, the definition of functor F can be simplified to
functor F () = X
thanks to subtyping on functor signatures.
Note that in most situations, component expressions provide a more convenient means to create dynamic components. However, the Create functor enables the creation of higher-order components.
localizes url using defaultResolver and attempts to unpickle a first-class component from the file found, which it returns upon success. Raises IO.Io if resolving, loading or unpickling fails.
pickles com and saves it to a new file with name s. Raises IO.Io if pickling or saving fails.
returns a new component manager with a component table empty but for the virtual machine's safe built-in components and the component manager itself. The returned component manager uses resolver to locate its components. Delegated requests are passed on to the default manager.