From bb912b081ed339e4a5419bd3d2ffd7465f2f72d3 Mon Sep 17 00:00:00 2001 From: nodist Date: Mon, 27 Jul 2026 17:17:56 -0400 Subject: bottom up redesign --- docs/type_system/function.md | 158 ------------------------------------------- 1 file changed, 158 deletions(-) delete mode 100644 docs/type_system/function.md (limited to 'docs/type_system/function.md') diff --git a/docs/type_system/function.md b/docs/type_system/function.md deleted file mode 100644 index 1099a55..0000000 --- a/docs/type_system/function.md +++ /dev/null @@ -1,158 +0,0 @@ -# Function - ---- - -```text -STATELESS : NATIVE | NATIVE_INLINE | PROCESS | GENERATOR | REGEX_GENERATOR - -STATEFUL : TASK | ITERATOR | CLOSURE | BOUND | REGEX - -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, *parent_function, *return_type, *var_list; -} kpl_type_body_function; -``` - -# Alias - -```text -Fn[Generic.T; Collection[VAR_TREE_LIST; TYPE.SYMBOL]] `alias Function[...] -``` - -# Inline Definition - -```text -([I64.x; I64.y] x + y) // Fn[Any; I64.x; I64.y] -([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 - -Native C code that can be called async - -## Native Inline - -Native C code that cannot be called async, has to be inline - -## Task - -A queue-able function in a process or iterator - -## Process - -A list of tasks with state - -## Generator - -A function for creating an iterator - -## Regex Generator - -A function for creating Regular Expression matcher - -## Iterator - -A task creator with state, cannot take arguments, can be called until done - -## Closure - -A task creator with state that can take arguments - -## Bound - -A function with some arguments already set - -## Regex - -Invoked regular expression matcher - -# Returning - -## Return Type Inference - -If a return type is not specified it is inferred a type checking time - -## \`return - -The return operation type is Void with the `%return` qualifier - -```text -%return Void -``` -This qualifier is used when type checking branches that should return value, indicating this branch is valid - -## Transient Union Return Chaining - -# Iterating - -## \`yield - -Yielding wraps the value in the transient union `Iteration` - -Return `Void` to stop iteration - -```text -fn : ([I64.n] @ 1 < n {[x] `yield 2 * x; n +: 1 } ) -it : fn `sync 10 -// invoking -@ it {[v] `log v } // 2 4 6 8 10 12 14 16 18 20 -// same as above -@ { - # `sync it { - .value {[v] `log v } - .done { `break } - } -} -``` - -## Range `..` - -# Calling - -## \`async - -Asynchronous call - -```text -task : `async fn -value : `await task -``` - -## \`sync - -Synchronous call - -If the callee is a process, an inline await with async is used - -```text -fn `sync args // can be turned into `await fn `async args -``` - -# Binding - -## \`bind - -# Type Inference - -The argument types of anonymous functions passed as an argument can be inferred -- cgit v1.2.3