Single-callable wrapper schemas with stored callable context and one declared call signature.
"Function" use exposes the module's public names. Name-specific imports such as "Function.Function" use, "Function.Function2" use, or "Function.makeFunction" use expose only selected names.
Function2 constructs one wrapper schema with explicit callable-context storage size and one declared call signature.Function constructs the same kind of wrapper schema with the default 32-byte callable-context storage.makeFunction constructs one Function value and stores one callable in it in a single step.(signature dataSize -- function)Constructs one function-wrapper schema with explicit callable-context storage size and one declared call signature.
SCHEMA_NAME: reported schema name. The reported name is always "Function".DATA_SIZE: storage reserved for the callable context.Signature: declared public call signature used by the wrapper.data and pad: callable-context storage.vtable: dynamic dispatch entry for copy, call, destroy, and init operations.assign (callable --): stores one callable in the wrapper. Sized callable contexts must fit into DATA_SIZE. Depending on callable schema and mutability, assignment may consume the supplied value.CALL (-- result): calls the stored callable according to Signature.hasContext (-- valid): reports whether a callable is currently stored.release (--): destroys the stored callable and returns the wrapper to the empty state.ASSIGN (other --): copies another wrapper of the same schema."Function.Function2" use
"control" use
{} () {} [
({value: Int32;} () {}) 48 Function2 .DATA_SIZE printStack _:;
] "main" exportFunction
48
"Function.Function2" use
"String" use
"control" use
{} Int32 {} [
code: {value1: Int64; value0: Int32;} Real32 {} codeRef;
[swap drop Int32 cast 5 + Real32 cast] !code
function: ({value1: Int64; value0: Int32;} Real32 {}) 48 Function2;
@code @function.assign
("has=" @function.hasContext LF
"call=" 7 11i64 function 12.0r32 same LF) printList
0
] "main" exportFunction
has=TRUE
call=TRUE
DATA_SIZE must be at least 8.DATA_SIZE.assign stores one callable and makes hasContext become TRUE.release destroys the stored callable and restores the same empty state as fresh construction.CALL is invalid while the wrapper has no stored callable context.ASSIGN replaces the current stored state with a copy of another wrapper of the same schema.(signature -- function)Constructs one function-wrapper schema with the default 32-byte callable-context storage.
"Function.Function" use
"Function.makeFunction" use
"String" use
"control" use
{} Int32 {} [
code: {value1: Int64; value0: Int32;} Real32 {} codeRef;
[swap drop Int32 cast 11 + Real32 cast] !code
function: ({value1: Int64; value0: Int32;} Real32 {}) Function;
("has0=" @function.hasContext LF) printList
@code @function.assign
("has1=" @function.hasContext LF
"call1=" 17 19i64 function 30.0r32 same LF) printList
@function.release
("has2=" @function.hasContext LF) printList
function2: @code ({value1: Int64; value0: Int32;} Real32 {}) makeFunction;
("has3=" @function2.hasContext LF
"call2=" 23 29i64 function2 40.0r32 same LF) printList
0
] "main" exportFunction
has0=FALSE
has1=TRUE
call1=TRUE
has2=FALSE
has3=TRUE
call2=TRUE
"Function.Function" use
"String" use
"control" use
{} Int32 {} [
function0: ({value1: Int64; value0: Int32;} Real32 {}) Function;
function1: ({value1: Int64; value0: Int32;} Real32 {}) Function;
code0: {value1: Int64; value0: Int32;} Real32 {} codeRef;
[swap drop Int32 cast 11 + Real32 cast] !code0
@code0 @function0.assign
code1: {value1: Int64; value0: Int32;} Real32 {} codeRef;
[swap drop Int32 cast 13 + Real32 cast] !code1
@code1 @function1.assign
@function0 const @function1 set
("call0=" 17 19i64 function0 30.0r32 same LF
"call1=" 23 29i64 function1 34.0r32 same LF
"has0=" @function0.hasContext LF
"has1=" @function1.hasContext LF) printList
0
] "main" exportFunction
call0=TRUE
call1=TRUE
has0=TRUE
has1=TRUE
(callable signature -- function)Constructs one Function value from one callable and one signature in a single step.
Function.assign.