From 224c245a875a6f28c01e93d037329c708ef81dd4 Mon Sep 17 00:00:00 2001 From: nodist Date: Wed, 15 Jul 2026 20:40:49 -0400 Subject: type var definitions --- docs/type_system/function.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'docs/type_system/function.md') diff --git a/docs/type_system/function.md b/docs/type_system/function.md index 129411c..1099a55 100644 --- a/docs/type_system/function.md +++ b/docs/type_system/function.md @@ -7,15 +7,16 @@ STATELESS : NATIVE | NATIVE_INLINE | PROCESS | GENERATOR | REGEX_GENERATOR STATEFUL : TASK | ITERATOR | CLOSURE | BOUND | REGEX -Function[[MODE | STATELESS | STATEFUL]; JIT; IR; Body; RETURN_TYPE; Collection[NAME_LIST; TYPE.SYMBOL]] +Function[[MODE | STATELESS | STATEFUL]; counters; JIT; IR; Body; Parent_Fn; RETURN_TYPE; Collection[NAME_LIST; TYPE.SYMBOL]] ``` ## Type Body Object Definitions ```c typedef struct { + int8_t process_state_id_counter, general_register_id_counter, xmm_register_id_counter, locals_counter; void *jit; - kpl_type *ir, *body, *return_type, *var_list; + kpl_type *ir, *body, *parent_function, *return_type, *var_list; } kpl_type_body_function; ``` @@ -32,6 +33,18 @@ Fn[Generic.T; Collection[VAR_TREE_LIST; TYPE.SYMBOL]] `alias Function[...] ([I64; I64.x; I64.y] x + y) // Fn[I64; I64.x; I64.y] ``` +# Casting To Functions + +```text +body : (x + y) +add_i64 : Fn[I64; I64.x; I64.y] $ body +add_f64 : Fn[F64.x; F64.y] $ body // return type is inferred +``` + +### Copy By Cast + +Casting a list to a function requires a copy of the list made for type checking and evaluation, use inline definitions if the list is meant to be a single function + # Function Classes ## Native @@ -142,4 +155,4 @@ fn `sync args // can be turned into `await fn `async args # Type Inference -The argument types of anonymous functions passed as an argument can be inhered +The argument types of anonymous functions passed as an argument can be inferred -- cgit v1.2.3