use

use (moduleDescriptor --)

Inputs

Outputs

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.

Behavior

Example

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.

Expected Output During Compilation

-- 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

See also