codeRef (inputsSchema output options -- code)inputsSchema: Descriptor of the Code input stack.output: Descriptor of the Code output stack.options: Descriptor of the Code calling options.code: Constructed Code value.codeRef is a Code schema constructor. A callable signature is formed from an input descriptor, an output descriptor, an options descriptor, and codeRef.
codeRef does not compile a body and does not create locals from the names written inside inputsSchema. Those names only describe the callable signature; they do not become locals in the surrounding scope. The result is a known NIL Code value of that signature.
inputsSchema supplies the input schema as a Dict or the empty Tuple ().output supplies the output schema.options supplies signature options as a Dict or the empty Tuple (). See Options descriptor below for the recognized fields.NIL Code value of that schema.NIL Code value, not a compiled function body.codeRef? reports TRUE for the result, while code? reports FALSE.call, because call rejects known NIL Code values.isConst reports TRUE for the result, while known? reports FALSE because the value is still NIL.NIL code comes from exportFunction, importFunction, or assignment of a matching Block to a Code destination.The options input is a Dict whose fields configure the resulting Code schema, or the empty Tuple () when no options are needed. The empty Dict {} is also valid and equivalent to (). Every option field must be non-static and known. Unrecognized field names are invalid.
Two option fields are recognized:
| Name | Schema | Default | Meaning |
|---|---|---|---|
convention |
Text | absent = LLVM default | LLVM calling-convention keyword applied to the function declaration or definition. An empty Text "" also selects the LLVM default. Typical values include "ccc" (C calling convention) and "x86_stdcallcc". The Standard Library module conventions exports portable names cdecl and stdcall that resolve to the correct string for the current target. |
variadic |
Cond | absent = FALSE |
When TRUE, the function accepts additional arguments after its declared inputs. At call sites the additional arguments are passed as a List or Tuple placed on the data stack below the declared inputs. Each item of that Struct must be non-Meta. |
{} 0 {} [
"-- empty signature --" printCompilerMessage
{} () {} codeRef printStack _:;
"-- non-empty signature is still only a signature value --" printCompilerMessage
{ value: 0; } 0 {} codeRef printStack _:;
"-- family checks --" printCompilerMessage
{ value: 0; } 0 {} codeRef codeRef? printStack _:;
{ value: 0; } 0 {} codeRef code? printStack _:;
{ value: 0; } 0 {} codeRef known? printStack _:;
{ value: 0; } 0 {} codeRef isConst printStack _:;
"-- convention option --" printCompilerMessage
{} () {convention: "ccc";} codeRef printStack _:;
"-- variadic option --" printCompilerMessage
{format: 0nx;} 0 {convention: "ccc"; variadic: TRUE;} codeRef printStack _:;
0
] "main" exportFunction
-- empty signature --
{} () {} codeRef CNIL
-- non-empty signature is still only a signature value --
{value: Int32;} Int32 {} codeRef CNIL
-- family checks --
TRUE
FALSE
FALSE
TRUE
-- convention option --
{} () {convention: "ccc";} codeRef CNIL
-- variadic option --
{format: Natx;} Int32 {convention: "ccc"; variadic: TRUE;} codeRef CNIL
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.use builtin (moduleDescriptor --) Imports public names from a module path named by known Text, or imports one selected public name when the descriptor's final dot separates the module path from that name.