nomen-lang 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOMEN_AGENTS.md CHANGED
@@ -100,7 +100,7 @@ func safe = (string[] s, int i: i >= 0 && i < s.length, out string) {
100
100
  | -------- | ---------------------------------------------- |
101
101
  | `ref T` | mutable borrow; caller must also write `ref` |
102
102
  | `view T` | read-only borrow |
103
- | `mov T` | transfer ownership; caller writes `mov` |
103
+ | `move T` | transfer ownership; caller writes `move` |
104
104
  | `out T` | output parameter, assigned inside the function |
105
105
 
106
106
  `const` values cannot be passed to `ref` — rebind the caller as `var` first.
@@ -150,10 +150,10 @@ declarations, so never import a sibling. Only cross-namespace references
150
150
  Failures are signalled via return values — nullable results, status structs,
151
151
  or boolean + out-parameter pairs. There is no `throw`/`try`/`catch`.
152
152
 
153
- `Result<T, E>` is declared `strict`: a call returning it must bind or match
153
+ `Result<T, E>` is declared `must_use`: a call returning it must bind or match
154
154
  the value (`var _ = f.close()` to discard deliberately; a bare `f.close()`
155
155
  statement is a compile error). Any enum or bitset can opt into this with the
156
- `strict` modifier.
156
+ `must_use` modifier.
157
157
 
158
158
  ## Tests
159
159
 
@@ -445,11 +445,11 @@ pub struct Buffer<T> {
445
445
  }
446
446
 
447
447
  // Move a value out of a T_SIZE-sized slot: return it and zero the slot so the
448
- // buffer no longer holds a (possibly owning) copy. Declared `mov out T` so
448
+ // buffer no longer holds a (possibly owning) copy. Declared `move out T` so
449
449
  // the result is treated as OWNED by the borrow checker — the slot is
450
450
  // relinquished, so the caller is the sole remaining owner. The value
451
451
  // counterpart of ClassBuffer.move_int — used by List.pop for any value T.
452
- inline func move_T = (ref self, int i: i >= 0 && i < self.cap, mov out T) {
452
+ inline func move_T = (ref self, int i: i >= 0 && i < self.cap, move out T) {
453
453
  ```
454
454
  #arch: c
455
455
  T* _slots = (T*)(unsigned long long)self->data;
@@ -218,7 +218,7 @@ pub class Channel: Sendable {
218
218
  // (the node's copy is moved out — the payload leaves the channel, and a
219
219
  // second receive of the same message is not possible). The fat (ptr, len)
220
220
  // pair survives intact. Pair with send_string.
221
- pub func receive_string = (self, mov out string) {
221
+ pub func receive_string = (self, move out string) {
222
222
  ```
223
223
  #arch: c
224
224
  pthread_mutex_lock((pthread_mutex_t *)self->mu);
@@ -175,14 +175,14 @@ pub struct ClassBuffer<T> {
175
175
  }
176
176
 
177
177
  // Move a class pointer out of a slot: return it and zero the slot so the
178
- // buffer no longer references it. Declared `mov out T` so the borrow
178
+ // buffer no longer references it. Declared `move out T` so the borrow
179
179
  // checker treats the result as OWNED — the slot is relinquished, so the
180
180
  // caller is the sole remaining owner. This is the owning-extract primitive
181
181
  // (parallel to List.pop); use it (not load_T) when transferring ownership
182
182
  // out of a ClassBuffer slot, or moving a value into a fresh owning
183
183
  // container — load_T returns a BORROW (the slot is unchanged) and storing
184
184
  // it elsewhere would create shared ownership (double-free at destroy).
185
- inline func move_T = (ref self, int i: i >= 0 && i < self.cap, mov out T) {
185
+ inline func move_T = (ref self, int i: i >= 0 && i < self.cap, move out T) {
186
186
  ```
187
187
  #arch: c
188
188
  long *slots = (long*)(unsigned long long)self->data;
@@ -42,8 +42,8 @@ pub struct Console {
42
42
  }
43
43
 
44
44
  // Read one line from stdin (newline stripped). The raw body mallocs the
45
- // buffer — `mov out string` transfers ownership to the caller.
46
- pub func read_line = (mov out string) {
45
+ // buffer — `move out string` transfers ownership to the caller.
46
+ pub func read_line = (move out string) {
47
47
  ```
48
48
  #arch: c
49
49
  int cap = 16;
@@ -125,8 +125,8 @@ pub struct Console {
125
125
  }
126
126
 
127
127
  // The platform name ("macos" / "ios" / …). The raw body strdups a static
128
- // string — `mov out string` transfers the owned copy to the caller.
129
- pub func platform = (mov out string) {
128
+ // string — `move out string` transfers the owned copy to the caller.
129
+ pub func platform = (move out string) {
130
130
  ```
131
131
  #arch: c
132
132
  #platform: macos
@@ -14,7 +14,7 @@ pub struct Graph<T>: Enumerable {
14
14
  var node_count = 0
15
15
  var edge_count = 0
16
16
 
17
- pub func add_node = (ref self, mov T value) {
17
+ pub func add_node = (ref self, move T value) {
18
18
  var int idx = self.node_count
19
19
  self.values.grow_T(idx + 1)
20
20
  self.values.store_T(idx, value)
@@ -13,7 +13,7 @@ pub struct LinkedList<T>: Enumerable {
13
13
  var int head = -1
14
14
  var count = 0
15
15
 
16
- pub func add = (ref self, mov T value) {
16
+ pub func add = (ref self, move T value) {
17
17
  var int idx = self.count
18
18
  self.values.grow_T(idx + 1)
19
19
  self.values.store_T(idx, value)
@@ -5,7 +5,7 @@ pub struct List<T>: Viewable {
5
5
  var length = 0
6
6
  var Buffer<T> items = Buffer<T>()
7
7
 
8
- pub func push = (ref self, mov T value) {
8
+ pub func push = (ref self, move T value) {
9
9
  if self.length >= self.items.cap {
10
10
  var new_cap = 4
11
11
  var int old_cap = self.items.cap
@@ -18,7 +18,7 @@ pub struct List<T>: Viewable {
18
18
  self.length += 1
19
19
  }
20
20
 
21
- pub func pop = (ref self, mov out T) {
21
+ pub func pop = (ref self, move out T) {
22
22
  if self.length <= 0 {
23
23
  return self.items.move_T(0)
24
24
  }
@@ -57,7 +57,7 @@ pub struct List<T>: Viewable {
57
57
  return self.items.slice(start, end)
58
58
  }
59
59
 
60
- pub func set = (ref self, int i: i >= 0 && i < self.length, mov T value) {
60
+ pub func set = (ref self, int i: i >= 0 && i < self.length, move T value) {
61
61
  self.items.replace_T(i, value)
62
62
  }
63
63
 
@@ -24,7 +24,7 @@ pub struct Map<TK: Hashable + Equatable, TV> {
24
24
  }
25
25
  }
26
26
 
27
- pub func set = (ref self, mov TK key, mov TV value) {
27
+ pub func set = (ref self, move TK key, move TV value) {
28
28
  var int cap = self.keys.cap
29
29
  if cap == 0 {
30
30
  cap = self.keys.alloc_T(8)
@@ -166,9 +166,9 @@ pub struct Map<TK: Hashable + Equatable, TV> {
166
166
  }
167
167
 
168
168
  func rehash = (ref self, int new_cap) {
169
- var Buffer<TK> old_keys = mov self.keys swap Buffer<TK>()
170
- var Buffer<TV> old_values = mov self.values swap Buffer<TV>()
171
- var Buffer<int> old_used = mov self.used swap Buffer<int>()
169
+ var Buffer<TK> old_keys = move self.keys swap Buffer<TK>()
170
+ var Buffer<TV> old_values = move self.values swap Buffer<TV>()
171
+ var Buffer<int> old_used = move self.used swap Buffer<int>()
172
172
  var int old_cap = old_keys.cap
173
173
 
174
174
  self.keys.alloc_T(new_cap)
@@ -190,7 +190,7 @@ pub struct Map<TK: Hashable + Equatable, TV> {
190
190
  // move_T results.
191
191
  var TK k = old_keys.move_T(i)
192
192
  var TV v = old_values.move_T(i)
193
- self.set(mov k, mov v)
193
+ self.set(move k, move v)
194
194
  }
195
195
  }
196
196
  }
@@ -1,4 +1,4 @@
1
- pub strict enum Result<T, E> {
1
+ pub must_use enum Result<T, E> {
2
2
  case ok(T value)
3
3
  case error(E error)
4
4
  }
@@ -12,7 +12,7 @@ pub struct Set<T: Hashable + Equatable> {
12
12
  var Buffer<T> slots = Buffer<T>()
13
13
  var used = Buffer<int>()
14
14
 
15
- pub func add = (ref self, mov T value) {
15
+ pub func add = (ref self, move T value) {
16
16
  var int cap = self.slots.cap
17
17
  if cap == 0 {
18
18
  cap = self.slots.alloc_T(8)
@@ -148,8 +148,8 @@ pub struct Set<T: Hashable + Equatable> {
148
148
  }
149
149
 
150
150
  func rehash = (ref self, int new_cap) {
151
- var Buffer<T> old_slots = mov self.slots swap Buffer<T>()
152
- var Buffer<int> old_used = mov self.used swap Buffer<int>()
151
+ var Buffer<T> old_slots = move self.slots swap Buffer<T>()
152
+ var Buffer<int> old_used = move self.used swap Buffer<int>()
153
153
  var int old_cap = old_slots.cap
154
154
 
155
155
  self.slots.alloc_T(new_cap)
@@ -168,7 +168,7 @@ pub struct Set<T: Hashable + Equatable> {
168
168
  // once the new buffer has made its own copy — passing it inline
169
169
  // would orphan the move_T result.
170
170
  var T v = old_slots.move_T(i)
171
- self.add(mov v)
171
+ self.add(move v)
172
172
  }
173
173
  }
174
174
  }
@@ -156,9 +156,9 @@ pub struct File {
156
156
  }
157
157
 
158
158
  // Read every byte from the current position to EOF and return it. Sets
159
- // `eof` and `error`. Declared `mov out string`: the raw body mallocs a
159
+ // `eof` and `error`. Declared `move out string`: the raw body mallocs a
160
160
  // fresh buffer and hands ownership to the caller.
161
- func raw_read_all = (ref self, mov out string) {
161
+ func raw_read_all = (ref self, move out string) {
162
162
  ```
163
163
  #arch: c
164
164
  FILE *f = (FILE*)(unsigned long long)self->handle;
@@ -268,8 +268,8 @@ pub struct File {
268
268
 
269
269
  // Read up to the next '\n' (the newline is not included). Sets `eof`
270
270
  // when the end of the file is reached and `error` on failure. The raw
271
- // body mallocs a fresh buffer — `mov out string` transfers it.
272
- func raw_read_line = (ref self, mov out string) {
271
+ // body mallocs a fresh buffer — `move out string` transfers it.
272
+ func raw_read_line = (ref self, move out string) {
273
273
  ```
274
274
  #arch: c
275
275
  FILE *f = (FILE*)(unsigned long long)self->handle;
@@ -409,8 +409,8 @@ pub struct File {
409
409
 
410
410
  // Read up to `size` bytes from the current position. Sets `eof` if fewer
411
411
  // than `size` bytes remain and `error` on failure. The raw body mallocs a
412
- // fresh buffer — `mov out string` transfers it.
413
- func raw_read_chunk = (ref self, int size, mov out string) {
412
+ // fresh buffer — `move out string` transfers it.
413
+ func raw_read_chunk = (ref self, int size, move out string) {
414
414
  ```
415
415
  #arch: c
416
416
  FILE *f = (FILE*)(unsigned long long)self->handle;
@@ -583,7 +583,7 @@ pub struct File {
583
583
 
584
584
  // (static) Write `data` to `path` (replacing any existing contents) in
585
585
  // one open/write/close. A write failure is reported as `.error`, not
586
- // silently swallowed (the `strict` Result discard check forces this to
586
+ // silently swallowed (the `must_use` Result discard check forces this to
587
587
  // be deliberate).
588
588
  pub func write_all = (string path, string data, out Result<bool, FileError>) {
589
589
  var Result<bool, FileError> result = .error(FileError.other)
@@ -53,9 +53,9 @@ pub struct Http {
53
53
  // method string ("GET" / "POST"); a leading 'P' selects POST semantics
54
54
  // (sends `body` and the Content-* headers). Sets self->status (0 on
55
55
  // failure) and self->error, and returns the response body (empty string
56
- // on failure). The raw body mallocs the response — `mov out string`
56
+ // on failure). The raw body mallocs the response — `move out string`
57
57
  // transfers ownership to the caller.
58
- func raw_exchange = (ref self, string method, string url, string body, mov out string) {
58
+ func raw_exchange = (ref self, string method, string url, string body, move out string) {
59
59
  ```
60
60
  #arch: c
61
61
  #scope: file
@@ -1,7 +1,7 @@
1
1
  // FFI: the C library's heap-copy entry point (string.h). The adapter
2
2
  // marshals the fat string to the thin char* the C ABI expects; the string
3
3
  // result is re-wrapped with its length.
4
- extern func strdup = (string s, mov out string)
4
+ extern func strdup = (string s, move out string)
5
5
 
6
6
  /**
7
7
  * A UTF-8 text string — a heap-owned, length-tracked sequence of bytes
@@ -18,13 +18,13 @@ pub struct string: Stringable, Hashable, Equatable {
18
18
  return h
19
19
  }
20
20
 
21
- // Returns an OWNED copy of self (`mov out string`). Both backends hand
21
+ // Returns an OWNED copy of self (`move out string`). Both backends hand
22
22
  // back a fresh allocation the caller frees — never an alias of self's
23
23
  // storage — so the result can outlive the receiver (e.g. escape a match
24
24
  // branch that reclaims the scrutinee temp). Goes through the `strdup`
25
25
  // extern: the adapter marshals self.ptr to libc and re-wraps the copy
26
26
  // with its length.
27
- pub func to_string = (self, mov out string) {
27
+ pub func to_string = (self, move out string) {
28
28
  return strdup(self)
29
29
  }
30
30
 
@@ -69,10 +69,10 @@ pub class Task<T> : Sendable {
69
69
  // the full return value — including the 16-byte fat-string pair — and the
70
70
  // trampoline writes the function's return value there before exiting.
71
71
  // The result is MOVED OUT: the slot is zeroed as the value leaves, and
72
- // `mov out T` marks the caller as the owner. Call it once; a second call
72
+ // `move out T` marks the caller as the owner. Call it once; a second call
73
73
  // returns the zero value. For tasks with no return value (void
74
74
  // functions), returns the zero value.
75
- pub func result = (ref self, mov out T) {
75
+ pub func result = (ref self, move out T) {
76
76
  ```
77
77
  #arch: c
78
78
  if (self->future) {
@@ -14,9 +14,9 @@
14
14
  **/
15
15
  pub struct Json {
16
16
  // Serialize a string to a JSON string literal, escaping the special
17
- // characters ", \, newline, tab and carriage return. `mov out string`:
17
+ // characters ", \, newline, tab and carriage return. `move out string`:
18
18
  // returns the StringBuilder's owned heap copy.
19
- pub func serialize = (string value, mov out string) {
19
+ pub func serialize = (string value, move out string) {
20
20
  var sb = StringBuilder()
21
21
  sb.append_char('"')
22
22
  var i = 0
@@ -50,8 +50,8 @@ pub struct Json {
50
50
  }
51
51
 
52
52
  // Deserialize a JSON string literal to the raw, unescaped value.
53
- // `mov out string`: returns the StringBuilder's owned heap copy.
54
- pub func deserialize = (string json, mov out string) {
53
+ // `move out string`: returns the StringBuilder's owned heap copy.
54
+ pub func deserialize = (string json, move out string) {
55
55
  var sb = StringBuilder()
56
56
  var int len = json.length
57
57
  var i = 0
@@ -30,9 +30,9 @@ pub struct Regex {
30
30
  }
31
31
 
32
32
  // Return the first substring of input matching pattern, or "" if none.
33
- // `mov out string`: the built match (or the copied empty literal) is
33
+ // `move out string`: the built match (or the copied empty literal) is
34
34
  // handed to the caller as an owned value.
35
- pub func match = (string pattern, string input, mov out string) {
35
+ pub func match = (string pattern, string input, move out string) {
36
36
  var match_result = ""
37
37
  var int pat_len = pattern.length
38
38
  var int len = input.length
@@ -13,7 +13,7 @@ pub struct Tree<T>: Enumerable {
13
13
  var parents = Buffer<int>()
14
14
  var count = 0
15
15
 
16
- pub func add = (ref self, mov T value) {
16
+ pub func add = (ref self, move T value) {
17
17
  const int idx = self.count
18
18
  self.values.grow_int(idx + 1)
19
19
  const int v = value
@@ -12,7 +12,7 @@ pub struct bool: Stringable, Hashable, Equatable {
12
12
  * @param self: the boolean
13
13
  * @out string: the boolean as a string value (`"true"` or `"false"`)
14
14
  **/
15
- pub func to_string = (self, mov out string) {
15
+ pub func to_string = (self, move out string) {
16
16
  ```
17
17
  #arch: c
18
18
  int length = snprintf(NULL, 0, "%s", self ? "true" : "false");
@@ -6,7 +6,7 @@ pub struct char: Stringable, Hashable, Equatable {
6
6
  return self as uint
7
7
  }
8
8
 
9
- pub func to_string = (self, mov out string) {
9
+ pub func to_string = (self, move out string) {
10
10
  ```
11
11
  #arch: c
12
12
  int length = snprintf(NULL, 0, "%c", self);
@@ -2,7 +2,7 @@
2
2
  * A double-precision (64-bit) floating-point number
3
3
  **/
4
4
  pub struct float: Stringable {
5
- pub func to_string = (self, mov out string) {
5
+ pub func to_string = (self, move out string) {
6
6
  ```
7
7
  #arch: c
8
8
  int length = snprintf(NULL, 0, "%f", self);
@@ -2,7 +2,7 @@
2
2
  * A signed double-precision (64-bit) floating-point number
3
3
  **/
4
4
  pub struct float32: Stringable {
5
- pub func to_string = (self, mov out string) {
5
+ pub func to_string = (self, move out string) {
6
6
  ```
7
7
  #arch: c
8
8
  int length = snprintf(NULL, 0, "%f", self);
@@ -2,7 +2,7 @@
2
2
  * A signed double-precision (64-bit) floating-point number
3
3
  **/
4
4
  pub struct float64: Stringable {
5
- pub func to_string = (self, mov out string) {
5
+ pub func to_string = (self, move out string) {
6
6
  ```
7
7
  #arch: c
8
8
  int length = snprintf(NULL, 0, "%f", self);
@@ -6,7 +6,7 @@ pub struct int: Stringable, Hashable, Equatable {
6
6
  return self as uint
7
7
  }
8
8
 
9
- pub func to_string = (self, mov out string) {
9
+ pub func to_string = (self, move out string) {
10
10
  ```
11
11
  #arch: c
12
12
  int length = snprintf(NULL, 0, "%ld", self);
@@ -6,7 +6,7 @@ pub struct int16: Stringable, Hashable, Equatable {
6
6
  return self as uint
7
7
  }
8
8
 
9
- pub func to_string = (self, mov out string) {
9
+ pub func to_string = (self, move out string) {
10
10
  ```
11
11
  #arch: c
12
12
  int length = snprintf(NULL, 0, "%d", self);
@@ -6,7 +6,7 @@ pub struct int32: Stringable, Hashable, Equatable {
6
6
  return self as uint
7
7
  }
8
8
 
9
- pub func to_string = (self, mov out string) {
9
+ pub func to_string = (self, move out string) {
10
10
  ```
11
11
  #arch: c
12
12
  int length = snprintf(NULL, 0, "%d", self);
@@ -6,7 +6,7 @@ pub struct int64: Stringable, Hashable, Equatable {
6
6
  return self as uint
7
7
  }
8
8
 
9
- pub func to_string = (self, mov out string) {
9
+ pub func to_string = (self, move out string) {
10
10
  ```
11
11
  #arch: c
12
12
  int length = snprintf(NULL, 0, "%lld", self);
@@ -6,7 +6,7 @@ pub struct int8: Stringable, Hashable, Equatable {
6
6
  return self as uint
7
7
  }
8
8
 
9
- pub func to_string = (self, mov out string) {
9
+ pub func to_string = (self, move out string) {
10
10
  ```
11
11
  #arch: c
12
12
  int length = snprintf(NULL, 0, "%d", self);
@@ -2,7 +2,7 @@
2
2
  * An unsigned double-precision (64-bit) floating-point number
3
3
  **/
4
4
  pub struct ufloat: Stringable {
5
- pub func to_string = (self, mov out string) {
5
+ pub func to_string = (self, move out string) {
6
6
  ```
7
7
  #arch: c
8
8
  int length = snprintf(NULL, 0, "%f", self);
@@ -2,7 +2,7 @@
2
2
  * An unsigned double-precision (64-bit) floating-point number
3
3
  **/
4
4
  pub struct ufloat32: Stringable {
5
- pub func to_string = (self, mov out string) {
5
+ pub func to_string = (self, move out string) {
6
6
  ```
7
7
  #arch: c
8
8
  int length = snprintf(NULL, 0, "%f", self);
@@ -2,7 +2,7 @@
2
2
  * An unsigned double-precision (64-bit) floating-point number
3
3
  **/
4
4
  pub struct ufloat64: Stringable {
5
- pub func to_string = (self, mov out string) {
5
+ pub func to_string = (self, move out string) {
6
6
  ```
7
7
  #arch: c
8
8
  int length = snprintf(NULL, 0, "%f", self);
@@ -6,7 +6,7 @@ pub struct uint: Stringable, Hashable, Equatable {
6
6
  return self
7
7
  }
8
8
 
9
- pub func to_string = (self, mov out string) {
9
+ pub func to_string = (self, move out string) {
10
10
  ```
11
11
  #arch: c
12
12
  int length = snprintf(NULL, 0, "%ld", self);
@@ -6,7 +6,7 @@ pub struct uint16: Stringable, Hashable, Equatable {
6
6
  return self as uint
7
7
  }
8
8
 
9
- pub func to_string = (self, mov out string) {
9
+ pub func to_string = (self, move out string) {
10
10
  ```
11
11
  #arch: c
12
12
  int length = snprintf(NULL, 0, "%u", self);
@@ -6,7 +6,7 @@ pub struct uint32: Stringable, Hashable, Equatable {
6
6
  return self as uint
7
7
  }
8
8
 
9
- pub func to_string = (self, mov out string) {
9
+ pub func to_string = (self, move out string) {
10
10
  ```
11
11
  #arch: c
12
12
  int length = snprintf(NULL, 0, "%u", self);
@@ -6,7 +6,7 @@ pub struct uint64: Stringable, Hashable, Equatable {
6
6
  return self as uint
7
7
  }
8
8
 
9
- pub func to_string = (self, mov out string) {
9
+ pub func to_string = (self, move out string) {
10
10
  ```
11
11
  #arch: c
12
12
  int length = snprintf(NULL, 0, "%llu", self);
@@ -6,7 +6,7 @@ pub struct uint8: Stringable, Hashable, Equatable {
6
6
  return self as uint
7
7
  }
8
8
 
9
- pub func to_string = (self, mov out string) {
9
+ pub func to_string = (self, move out string) {
10
10
  ```
11
11
  #arch: c
12
12
  int length = snprintf(NULL, 0, "%d", self);
@@ -1,12 +1,12 @@
1
1
  # Result
2
2
 
3
- ## `strict enum Result<T, E>`
3
+ ## `must_use enum Result<T, E>`
4
4
 
5
5
  A generic result type with an `ok(T value)` success case and an
6
6
  `error(E error)` failure case. Monomorphized per concrete type-argument pair
7
7
  (e.g. `Result<int, string>`).
8
8
 
9
- `Result` is declared `strict`: a statement-position call that returns a
9
+ `Result` is declared `must_use`: a statement-position call that returns a
10
10
  `Result` is a compile error unless the value is bound or matched. Ignore it
11
11
  deliberately with `var _ = f.close()`, or handle both cases with `match`.
12
12