From f3e3fd0cdba8d2f9f49be279ac3c0ec87a44609b Mon Sep 17 00:00:00 2001 From: nodist Date: Wed, 3 Jun 2026 15:26:26 -0400 Subject: refs with more impl --- docs/application/index.md | 29 ++++++++++++++++++++++++----- docs/application/interface.md | 8 -------- docs/application/namespace.md | 13 +++++++++++++ docs/application/thread.md | 16 +++++++++++----- docs/language/index.md | 4 ++-- docs/language/operators.md | 2 ++ docs/language/ownership.md | 26 ++++++++++++++++++++++++++ docs/type_system/bit.md | 2 ++ docs/type_system/buffer.md | 2 +- docs/type_system/empty.md | 16 ++++++++++++++++ docs/type_system/lock.md | 2 ++ docs/type_system/ref.md | 2 ++ docs/type_system/shared.md | 8 ++------ 13 files changed, 103 insertions(+), 27 deletions(-) create mode 100644 docs/application/namespace.md (limited to 'docs') diff --git a/docs/application/index.md b/docs/application/index.md index 3809ac9..e7e719f 100644 --- a/docs/application/index.md +++ b/docs/application/index.md @@ -2,22 +2,41 @@ --- -## Requirements +# Requirements * Linux X64 * GNU Make * GCC with -std=gnu99 -fhardened -## Sections +# Sections * ##### [Interface](./interface.md) * ##### [Type](./type.md) * ##### [Pool](./pool.md) * ##### [Thread](./thread.md) +* ##### [Namespace](./namespace.md) * ##### [Testing](./testing.md) -## Invocation +# Invocation -### File +## Startup -### REPL +```c +void kpl_init(void); +``` + +## Main + +```c +void kpl_main(int argc, char *argv[]); +``` + +## File + +## REPL + +## Shutdown + +```c +void kpl_free(void) +``` diff --git a/docs/application/interface.md b/docs/application/interface.md index 1493aff..3f270bd 100644 --- a/docs/application/interface.md +++ b/docs/application/interface.md @@ -32,14 +32,6 @@ typedef int32_t kpl_any_print_fn(const kpl_any a, FILE *file, size_t idnt, uint3 typedef void kpl_any_free_fn(kpl_any a); -typedef struct { - kpl_any_hash_fn *hash_fn; - kpl_any_eq_fn *eq_fn; - kpl_any_cmp_fn *cmp_fn; - kpl_any_print_fn *print_fn; - kpl_any_free_fn *free_fn; -} kpl_any_interace; - typedef struct { any value, info; } kpl_result; diff --git a/docs/application/namespace.md b/docs/application/namespace.md new file mode 100644 index 0000000..47f6105 --- /dev/null +++ b/docs/application/namespace.md @@ -0,0 +1,13 @@ +# Namespace + +--- + +## Object Definitions + +# Native Registering + +# File Registering + +## Import + +## Export diff --git a/docs/application/thread.md b/docs/application/thread.md index 04d9c98..a11c01f 100644 --- a/docs/application/thread.md +++ b/docs/application/thread.md @@ -23,15 +23,21 @@ typedef struct _kpl_task { } kpl_task; typedef struct { - kpl_task *head, *tail; + kpl_task *queue_head, *queue_tail; pthread_t thread; } kpl_thread; -#define KPL_PROCESSES $(nproc) +#define KPL_THREADS $(nproc) -kpl_thread kpl_worker[KPL_PROCESSES] = {}; +_Atomic uint16_t running; // init to KPL_THREADS -_Atomic uint16_t kpl_worker_running = KPL_PROCESSES; +kpl_task *async_queue_head, *async_queue_tail; + +pthread_mutex_t async_mutex; + +pthread_cond_t async_cond; + +kpl_thread threads[KPL_THREADS]; ``` ## Per Process Task Queue @@ -236,7 +242,7 @@ fib : Fn[n] $ ( n < 2 { 1 } { + (fib `sync n - 1; fib `sync n - 2) } } - v : Vector[`fork_type fib] $ () + v : Array[`fork_type fib] $ () @ 1 .. I { v `push fib `async FIB } @ v {[fib_task] `print "fib(%) = %\n" `format (FIB; `wait fib_task) } `print "Complete\n" diff --git a/docs/language/index.md b/docs/language/index.md index fe97143..b63d3e4 100644 --- a/docs/language/index.md +++ b/docs/language/index.md @@ -133,9 +133,9 @@ Arguments are specified with a `[]` at the beginning of the `{}` @ condition {[args] statements } -@ condition {[.name] statements } +@.name condition { statements } -@ condition {[.name; args] statements } +@.name condition {[args] statements } ``` #### If `?` diff --git a/docs/language/operators.md b/docs/language/operators.md index d8ae378..7bfdd17 100644 --- a/docs/language/operators.md +++ b/docs/language/operators.md @@ -8,6 +8,8 @@ ## Cast `$` +## `log + ## ``print` ```text diff --git a/docs/language/ownership.md b/docs/language/ownership.md index 289846c..9af214b 100644 --- a/docs/language/ownership.md +++ b/docs/language/ownership.md @@ -4,10 +4,36 @@ # Copying +## Assignment + # Moving +## Assignment is not allowed for movable types that are not shared + +## Shared Types + ## To And From Functions +# Passing + +## References + +References are automatically taken if the function signature specifies ref + +```text +inc_push_to_ref : Fn[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) +} +`log int_array // Array[I64] $ (1; 2; 3) +`log float_array // Array[F64] $ (1.0; 2.0; 3.0) +``` + # Locking ## References diff --git a/docs/type_system/bit.md b/docs/type_system/bit.md index 41a6abd..b474156 100644 --- a/docs/type_system/bit.md +++ b/docs/type_system/bit.md @@ -16,6 +16,8 @@ Bit_representation `alias Enum[ Bit[Bit_size; Bit_representation] ``` +# Casting + # Alias ```text diff --git a/docs/type_system/buffer.md b/docs/type_system/buffer.md index aa5b0d3..c7c0354 100644 --- a/docs/type_system/buffer.md +++ b/docs/type_system/buffer.md @@ -15,7 +15,7 @@ Buffer[Buffer_repesentation; TYPE] ```text String `alias Buffer[.utf8; Void] -Vector[Any] `alias Buffer[.type; Any] +Array[Any] `alias Buffer[.type; Any] ``` # Operators diff --git a/docs/type_system/empty.md b/docs/type_system/empty.md index ab0226d..55bdcf1 100644 --- a/docs/type_system/empty.md +++ b/docs/type_system/empty.md @@ -5,3 +5,19 @@ Container type can be null ## Use with `Option` Union + +```text +make_array : Fn[yes] $ ( + ? yes { + `some Array $ (1; 2; 3) + `nome + } +) +v : make_array(...) // Empty[Array[I64]] $ .none OR Empty[Array[I64]] $ (.some : (1; 2; 3)) +# v { + .some {[x] `log x } // Array[I64] $ (1; 2; 3) + .none { ... } +} +// same as above +? v {[x] `log x } // Array[I64] $ (1; 2; 3) +``` diff --git a/docs/type_system/lock.md b/docs/type_system/lock.md index 86effac..b3227ca 100644 --- a/docs/type_system/lock.md +++ b/docs/type_system/lock.md @@ -2,6 +2,8 @@ --- +Prevent access to a parent while children are modifiable + ```text Lock[Name[...]; TYPE] ``` diff --git a/docs/type_system/ref.md b/docs/type_system/ref.md index 0d872c7..a5541c3 100644 --- a/docs/type_system/ref.md +++ b/docs/type_system/ref.md @@ -5,3 +5,5 @@ ```text Ref[TYPE] ``` + +A reference, cannot be assigned diff --git a/docs/type_system/shared.md b/docs/type_system/shared.md index 84366ab..82a70d7 100644 --- a/docs/type_system/shared.md +++ b/docs/type_system/shared.md @@ -12,10 +12,6 @@ Shared[TYPE] // Resolves to Shared[.unknown; TYPE] # Garbage Collection Method -```text -Shared[TYPE] -``` - ## Unknown Counting or tracing will determined later on @@ -27,9 +23,9 @@ Counting or tracing will determined later on # Mutating ```text -x : Shared[Vector] $ (1; 2; 3) +x : Shared[Array] $ (1; 2; 3) ^ x {[y] y `push 4 } -`log x // Shared[.counting; Vector[I64]] $ (1; 2; 3; 4) +`log x // Shared[.counting; Array[I64]] $ (1; 2; 3; 4) ``` -- cgit v1.2.3