x-lang

← Index

x/type/module

Module: the module registry as data – names, loaded state, exports, owners and environments.

The registry as data: (Module names), (Module loaded? ‘name), (Module exports ‘name), (Module owner ‘sym), (Module env ‘name).

Class Module

The module registry as data: which modules the session knows and which are loaded, what each exports, which module owns a name, and a module’s environment. (modules) and (help x/some/module) print the same facts.

(Module %entry name)

The (name . exports) entry provide recorded for name, or ().

Examples:

(first (Module %entry 'x/core/fn)) => 'x/core/fn
(null? (Module %entry 'x/no/such)) => #t

(Module names)

Every module name the session knows, sorted: the boot modules registered at boot and every module imported since, loaded or not.

Returns: LIST — Symbols, sorted by name

Examples:

(List includes? 'x/core/fn (Module names)) => #t

(Module loaded? name)

Whether the module has loaded and provided its exports.

Parameters:

Returns: BOOL — #t when the module’s provide has run

Examples:

(Module loaded? 'x/core/fn) => #t
(Module loaded? 'x/no/such) => #f

(Module exports name)

The names the module provides, as symbols, in provide order; a (global NAME) export is listed as NAME. () for a module that is not loaded.

Parameters:

Returns: LIST — Symbols

Examples:

(List includes? 'Fn (Module exports 'x/core/fn)) => #t

(Module owner name)

The module that provided name, or () when no module has.

Parameters:

Returns: SYMBOL — A module name, or ()

Examples:

(Module owner 'Fn) => 'x/core/fn

(Module env name)

The environment the module’s names live in: its own for a scoped module, a child of the root; the root for a module loaded by include. () for a module that is not loaded.

Parameters:

Returns: ANY — An environment, or ()

Examples:

(Env has? (Module env 'x/core/fn) 'Fn) => #t