From f1773b4959a35f28b37617f775f4fc1683e4f654 Mon Sep 17 00:00:00 2001 From: nodist Date: Sun, 12 Jul 2026 11:43:56 -0400 Subject: function types --- docs/application/type.md | 2 +- docs/language/ownership.md | 7 ++----- docs/type_system/empty.md | 2 +- docs/type_system/function.md | 11 +++++++++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/docs/application/type.md b/docs/application/type.md index 25a5863..793fb14 100644 --- a/docs/application/type.md +++ b/docs/application/type.md @@ -34,7 +34,7 @@ typedef struct _kpl_type { int32_t id, tree_weight; } var; } meta; - _Atomic int32_t ref_count; + _Atomic ssize_t ref_count; struct _kpl_type *prev, *next; kpl_type_body body; } kpl_type; diff --git a/docs/language/ownership.md b/docs/language/ownership.md index 2c5de36..26eebe1 100644 --- a/docs/language/ownership.md +++ b/docs/language/ownership.md @@ -19,14 +19,11 @@ References are automatically taken if the function signature specifies ref ```text -inc_push_to_ref : ([%ref x; y] - x `push y + 1 -) int_array : Array[I64] $ () float_array : Array[F64] $ () @ 0 .. 2 {[x] - inc_push_to_ref `sync (int_array, x) - inc_push_to_ref `sync (float_array, F64 $ x) + ([%ref x; y] x `push y + 1) `sync (int_array, x) + ([%ref x; y] x `push y + 1) `sync (float_array, F64 $ x) } `log int_array // Array[I64] $ (1; 2; 3) `log float_array // Array[F64] $ (1.0; 2.0; 3.0) diff --git a/docs/type_system/empty.md b/docs/type_system/empty.md index 5903c19..9466493 100644 --- a/docs/type_system/empty.md +++ b/docs/type_system/empty.md @@ -11,7 +11,7 @@ Container type can be null ## Use with `Result` Union ```text -make_array : ([yes] +make_array : ([Bool.yes] ? yes { `value Array $ (1; 2; 3) `null diff --git a/docs/type_system/function.md b/docs/type_system/function.md index 76430a5..129411c 100644 --- a/docs/type_system/function.md +++ b/docs/type_system/function.md @@ -76,6 +76,10 @@ 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 @@ -83,7 +87,6 @@ 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 @@ -97,7 +100,7 @@ Yielding wraps the value in the transient union `Iteration` Return `Void` to stop iteration ```text -fn : ([n] @ 1 < n {[x] `yield 2 * x; n +: 1 } ) +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 @@ -136,3 +139,7 @@ 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 inhered -- cgit v1.2.3