diff options
| author | nodist <kevin.comas.git@gmail.com> | 2026-07-15 20:40:49 -0400 |
|---|---|---|
| committer | nodist <kevin.comas.git@gmail.com> | 2026-07-15 20:40:49 -0400 |
| commit | 224c245a875a6f28c01e93d037329c708ef81dd4 (patch) | |
| tree | 7a368ccb80743651d5eb2f4b30a788ef70dae0ee /docs/type_system/function.md | |
| parent | 4c008d258f6fd23fd64e2a6b059448748d7f7d24 (diff) | |
type var definitions
Diffstat (limited to 'docs/type_system/function.md')
| -rw-r--r-- | docs/type_system/function.md | 19 |
1 files changed, 16 insertions, 3 deletions
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 |
