use (moduleDescriptor --)moduleDescriptor: Known module-path or selected-name descriptor Text.The input moduleDescriptor is known Text. It names a module path without the trailing .mpl. If it contains no dot after the last path separator, it names one module path. If it contains a dot after the last / or \, only that rightmost post-separator dot has special meaning: the text before it names the module path, and the text after it names one selected public name. Earlier dots, and any dots before the last path separator, remain part of the module path.
Loading a module with use also enables same-name lookup of that module's overload names. The whole-module form directly imports public non-overload names. The single-symbol form directly imports only the selected public name, which may itself be a public overload name. A private overload cannot be selected directly, but it still participates in same-name lookup after the module has been loaded.
moduleDescriptor must be known Text./ or \ separates the module path from a selected public name.useExample.mpl
overload virtual helper: 3;
virtual first: 1;
virtual second: 2;
test.mpl is the primary runnable example file. selectedNameExample.mpl records the separate selected-name import form.
test.mpl
"useExample" use
{} 0 {} [
"-- whole module imports public non-overload names --" printCompilerMessage
first printStack _:;
second printStack _:;
"-- overload still participates in lookup after whole-module load --" printCompilerMessage
helper printStack _:;
0
] "main" exportFunction
selectedNameExample.mpl
"useExample.second" use
{} 0 {} [
"-- selected public name --" printCompilerMessage
second printStack _:;
"-- overload still participates in lookup after selected-name load --" printCompilerMessage
helper printStack _:;
0
] "main" exportFunction
Module-loading wrapper lines are omitted below.
-- whole module imports public non-overload names --
1
2
-- overload still participates in lookup after whole-module load --
3
-- selected public name --
2
-- overload still participates in lookup after selected-name load --
3
NAME: ...; node — Pushes a name onto the name stack and creates a local by consuming that name and one data-stack value.codeRef builtin (inputsSchema output options -- code) Constructs a Code schema and pushes a known NIL Code value of that schema.def builtin (value name --) Creates a named local or field using a known Text name.exportFunction builtin (inputsSchema output options callable name --) Exports a named function built from a Block and a signature.importFunction builtin (inputsSchema output options name --) Declares or imports a named function with the supplied signature and binds it in the current scope as a Code local.importVariable builtin (schema name --) Creates a local that refers to an external variable of the requested non-Meta schema; the created local is treated as unknown.