exportFunction (inputsSchema output options callable name --)inputsSchema: Descriptor of the exported function input stack.output: Descriptor of the exported function output stack.options: Descriptor of the exported function calling options.callable: Block compiled as the exported body.name: Known exported function name.exportFunction constructs a function signature, compiles the supplied Block, records the resulting function declaration, and creates the exported function name in the current module.
The stack contract follows the declared signature. When the exported function starts at runtime, its declared inputs are on the data stack. Named access inside the body still requires explicit binding. Names written inside inputsSchema therefore belong only to the signature, not to the surrounding scope.
inputsSchema, output, and options are interpreted through the same signature-building logic as codeRef. In that logic, inputsSchema and options are Dict descriptors or the empty Tuple (). The recognized option fields are convention (Text) and variadic (Cond); see Options descriptor on the codeRef page for the full specification.name must be known, non-empty Text.NIL, but known? still reports FALSE for it.overload and private modifiers apply to the exported name. A pending virtual modifier is invalid here.exportExample.mpl
{} 0 {} [
"-- zero-input body compiled --" printCompilerMessage
7
] "seven" exportFunction
{ value: 0; } 0 {} [
value:;
"-- one-input body compiled --" printCompilerMessage
value 1 +
] "addOne" exportFunction
"-- exported name immediately usable here --" printCompilerMessage
@addOne printStack _:;
@addOne known? printStack _:;
test.mpl is the primary runnable example file.
test.mpl
"String" use
"exportExample.seven" use
"exportExample.addOne" use
{} 0 {} [
("-- zero-input function -- " seven "\n") printList
("-- one-input function -- " 5 addOne "\n") printList
@addOne known? printStack _:;
0
] "main" exportFunction
Module-loading wrapper lines are omitted below.
-- zero-input body compiled --
-- one-input body compiled --
-- exported name immediately usable here --
{value: Int32;} Int32 {} codeRef
FALSE
FALSE
-- zero-input function -- 7
-- one-input function -- 6
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.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.use builtin (moduleDescriptor --) Imports public names from a module path named by known Text, or imports one selected public name when the last dot after the last path separator separates the module path from that name.