nomen-lang 0.9.0 → 0.10.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.
Files changed (70) hide show
  1. package/core/System/Arena.nm +9 -7
  2. package/core/System/Array.nm +1 -1
  3. package/core/System/Atomic.nm +3 -3
  4. package/core/System/BigInt.nm +182 -23
  5. package/core/System/Buffer.nm +37 -35
  6. package/core/System/ClassBuffer.nm +18 -18
  7. package/core/System/Controls/Alert.nm +1 -1
  8. package/core/System/Controls/App.nm +5 -5
  9. package/core/System/Controls/Button.nm +1 -1
  10. package/core/System/Controls/CheckBox.nm +1 -1
  11. package/core/System/Controls/ColorPicker.nm +1 -1
  12. package/core/System/Controls/ComboBox.nm +1 -1
  13. package/core/System/Controls/Container.nm +34 -34
  14. package/core/System/Controls/DatePicker.nm +1 -1
  15. package/core/System/Controls/Form.nm +2 -2
  16. package/core/System/Controls/GroupBox.nm +1 -1
  17. package/core/System/Controls/ImageView.nm +1 -1
  18. package/core/System/Controls/Layout.nm +5 -5
  19. package/core/System/Controls/LevelIndicator.nm +1 -1
  20. package/core/System/Controls/ListView.nm +1 -1
  21. package/core/System/Controls/Menu.nm +1 -1
  22. package/core/System/Controls/NumberInput.nm +3 -3
  23. package/core/System/Controls/OtpInput.nm +2 -2
  24. package/core/System/Controls/OutlineView.nm +1 -1
  25. package/core/System/Controls/Pagination.nm +6 -6
  26. package/core/System/Controls/Popover.nm +1 -1
  27. package/core/System/Controls/Progress.nm +1 -1
  28. package/core/System/Controls/Radio.nm +1 -1
  29. package/core/System/Controls/Scrollable.nm +1 -1
  30. package/core/System/Controls/SearchField.nm +1 -1
  31. package/core/System/Controls/SecureField.nm +1 -1
  32. package/core/System/Controls/Segmented.nm +1 -1
  33. package/core/System/Controls/Select.nm +1 -1
  34. package/core/System/Controls/Separator.nm +1 -1
  35. package/core/System/Controls/Sheet.nm +1 -1
  36. package/core/System/Controls/Slider.nm +1 -1
  37. package/core/System/Controls/Spinner.nm +3 -3
  38. package/core/System/Controls/SplitView.nm +2 -2
  39. package/core/System/Controls/Stepper.nm +1 -1
  40. package/core/System/Controls/Switch.nm +1 -1
  41. package/core/System/Controls/Table.nm +1 -1
  42. package/core/System/Controls/Tabs.nm +1 -1
  43. package/core/System/Controls/Text.nm +1 -1
  44. package/core/System/Controls/TextBox.nm +1 -1
  45. package/core/System/Controls/TextView.nm +1 -1
  46. package/core/System/Controls/Toggle.nm +1 -1
  47. package/core/System/Controls/Toolbar.nm +1 -1
  48. package/core/System/Controls/Window.nm +11 -3
  49. package/core/System/Fiber.nm +16 -3
  50. package/core/System/Graph.nm +2 -2
  51. package/core/System/LinkedList.nm +8 -6
  52. package/core/System/List.nm +16 -13
  53. package/core/System/Map.nm +11 -9
  54. package/core/System/Random.nm +3 -3
  55. package/core/System/Set.nm +9 -7
  56. package/core/System/StableList.nm +7 -7
  57. package/core/System/Stream/File.nm +16 -16
  58. package/core/System/Stream/Http.nm +3 -3
  59. package/core/System/Stream/Tcp.nm +5 -5
  60. package/core/System/StringBuilder.nm +16 -16
  61. package/core/System/Task.nm +56 -64
  62. package/core/System/Test.nm +18 -18
  63. package/core/System/Text/Chars.nm +1 -1
  64. package/core/System/Text/Json.nm +12 -12
  65. package/core/System/Text/JsonTree.nm +8 -8
  66. package/core/System/Text/Regex.nm +20 -20
  67. package/core/System/Thread.nm +26 -3
  68. package/core/System/Tree.nm +19 -3
  69. package/dist/index.mjs +3036 -1845
  70. package/package.json +1 -1
@@ -23,13 +23,13 @@ pub struct Buffer<T> {
23
23
  // both backends. They run once per container op (never per element), so
24
24
  // the aarch64 inline-method ABI cost that keeps the per-limb load/store
25
25
  // primitives raw (see BigInt.nm) doesn't apply here.
26
- internal func alloc_u32 = (ref self, int size, out int: out >= size) {
26
+ internal func alloc_u32 = (ref self {}, int size, out int: out >= size) {
27
27
  self.cap = size
28
28
  self.data = calloc(size, 4)
29
29
  return self.cap
30
30
  }
31
31
 
32
- internal func grow_u32 = (ref self, int needed, out int: out >= needed) {
32
+ internal func grow_u32 = (ref self {}, int needed, out int: out >= needed) {
33
33
  if self.cap >= needed {
34
34
  return self.cap
35
35
  }
@@ -44,7 +44,7 @@ pub struct Buffer<T> {
44
44
  return self.cap
45
45
  }
46
46
 
47
- internal func zero_u32 = (ref self, int len) {
47
+ internal func zero_u32 = (ref self {}, int len) {
48
48
  memset(self.data, 0, len * 4)
49
49
  }
50
50
 
@@ -63,7 +63,7 @@ pub struct Buffer<T> {
63
63
  ```
64
64
  }
65
65
 
66
- internal inline func store_u32 = (ref self, int i: i >= 0 && i < self.cap, uint32 val) {
66
+ internal inline func store_u32 = (ref self {}, int i: i >= 0 && i < self.cap, uint32 val) {
67
67
  ```
68
68
  #arch: c
69
69
  ((unsigned int*)(unsigned long long)self->data)[i] = val;
@@ -77,7 +77,7 @@ pub struct Buffer<T> {
77
77
  ```
78
78
  }
79
79
 
80
- internal inline func store_or_u32 = (ref self, int i: i >= 0 && i < self.cap, uint32 val) {
80
+ internal inline func store_or_u32 = (ref self {}, int i: i >= 0 && i < self.cap, uint32 val) {
81
81
  ```
82
82
  #arch: c
83
83
  ((unsigned int*)(unsigned long long)self->data)[i] |= val;
@@ -109,7 +109,7 @@ pub struct Buffer<T> {
109
109
  ```
110
110
  }
111
111
 
112
- internal inline func store_u8 = (ref self, int i: i >= 0 && i < self.cap, uint8 val) {
112
+ internal inline func store_u8 = (ref self {}, int i: i >= 0 && i < self.cap, uint8 val) {
113
113
  ```
114
114
  #arch: c
115
115
  ((unsigned char*)(unsigned long long)self->data)[i] = val;
@@ -122,12 +122,12 @@ pub struct Buffer<T> {
122
122
  ```
123
123
  }
124
124
 
125
- internal func alloc_int = (ref self, int size, out int: out >= size) {
125
+ internal func alloc_int = (ref self {}, int size, out int: out >= size) {
126
126
  self.cap = size
127
127
  self.data = calloc(size, 8)
128
128
  return self.cap
129
129
  }
130
- internal func grow_int = (ref self, int needed, out int: out >= needed) {
130
+ internal func grow_int = (ref self {}, int needed, out int: out >= needed) {
131
131
  if self.cap >= needed {
132
132
  return self.cap
133
133
  }
@@ -156,7 +156,7 @@ pub struct Buffer<T> {
156
156
  ```
157
157
  }
158
158
 
159
- internal inline func store_int = (ref self, int i: i >= 0 && i < self.cap, int val) {
159
+ internal inline func store_int = (ref self {}, int i: i >= 0 && i < self.cap, int val) {
160
160
  ```
161
161
  #arch: c
162
162
  ((long*)(unsigned long long)self->data)[i] = val;
@@ -249,7 +249,7 @@ pub struct Buffer<T> {
249
249
  // relay — the same stack view the raw bodies build by hand, in typed
250
250
  // Nomen. The holder must clear the view afterwards (see clear_view):
251
251
  // an owning Buffer FIELD is destroyed by its holder's teardown.
252
- internal func init_view = (ref self, uint64 slab, int fill: fill >= 0) {
252
+ internal func init_view = (ref self {}, uint64 slab, int fill: fill >= 0) {
253
253
  self.data = slab
254
254
  self.cap = fill
255
255
  }
@@ -257,7 +257,7 @@ pub struct Buffer<T> {
257
257
  // Clear a view initialized by init_view: `data`/`cap` back to zero, so
258
258
  // the holder's own field destroy reclaims nothing (the slab's real owner
259
259
  // still owns it).
260
- internal func clear_view = (ref self) {
260
+ internal func clear_view = (ref self {}) {
261
261
  self.data = 0
262
262
  self.cap = 0
263
263
  }
@@ -270,7 +270,7 @@ pub struct Buffer<T> {
270
270
  // local — a local owning Buffer would be auto-destroyed at scope exit
271
271
  // and free the slab it only borrows.
272
272
  internal func store_in_slab = (
273
- ref self,
273
+ ref self {},
274
274
  uint64 slab,
275
275
  int fill: fill >= 0,
276
276
  int slot: slot >= 0,
@@ -278,10 +278,12 @@ pub struct Buffer<T> {
278
278
  ) {
279
279
  self.init_view(slab, fill)
280
280
  // `val` arrives owned from the container's `mv T` push parameter: a
281
- // value-struct element moves into the chunk slot (store_take — the
282
- // caller's storage zeroes, no deep copy); strings keep the
283
- // deep-copying store (their pair arrives by value).
284
- if T_IS_VALUE_STRUCT {
281
+ // value-struct element that OWNS resources moves into the chunk slot
282
+ // (store_take — the caller's storage zeroes, no deep copy). A
283
+ // non-owning value struct is a legal bare argument, so it keeps the
284
+ // copying store (taking it would zero the caller's copy); strings
285
+ // keep the deep-copying store too (their pair arrives by value).
286
+ if T_TAKES_OWNERSHIP {
285
287
  self.store_take(slot, val)
286
288
  } else {
287
289
  self.store(slot, val)
@@ -293,7 +295,7 @@ pub struct Buffer<T> {
293
295
  // the ownership-extracting primitive (used by e.g. List.pop) — unlike
294
296
  // load_int (a borrow read), it relinquishes the slot so the buffer no
295
297
  // longer owns the value.
296
- internal inline func move_int = (ref self, int i: i >= 0 && i < self.cap, out int) {
298
+ internal inline func move_int = (ref self {}, int i: i >= 0 && i < self.cap, out int) {
297
299
  ```
298
300
  #arch: c
299
301
  long *slots = (long*)(unsigned long long)self->data;
@@ -314,7 +316,7 @@ pub struct Buffer<T> {
314
316
  // Store into a slot, freeing the previous value when the buffer holds
315
317
  // owned class pointers (has_class_refs). For non-class buffers this is a
316
318
  // plain store, so it is safe to use anywhere store_int would be.
317
- internal inline func replace_int = (ref self, int i: i >= 0 && i < self.cap, int val) {
319
+ internal inline func replace_int = (ref self {}, int i: i >= 0 && i < self.cap, int val) {
318
320
  ```
319
321
  #arch: c
320
322
  ((long*)(unsigned long long)self->data)[i] = val;
@@ -328,7 +330,7 @@ pub struct Buffer<T> {
328
330
  ```
329
331
  }
330
332
 
331
- internal inline func zero_int = (ref self, int len) {
333
+ internal inline func zero_int = (ref self {}, int len) {
332
334
  memset(self.data, 0, len * 8)
333
335
  }
334
336
 
@@ -338,7 +340,7 @@ pub struct Buffer<T> {
338
340
  // structs of any width work correctly. Classes route to ClassBuffer<T> (per-element destroy), so T
339
341
  // reaching here is always a value type (primitive or struct).
340
342
 
341
- func alloc = (ref self, int size, out int: out >= size) {
343
+ func alloc = (ref self {}, int size, out int: out >= size) {
342
344
  // Reclaim the old slab before the fresh calloc (the raw body runs
343
345
  // for scalar / trivially-destructible elements — plain bytes, so a
344
346
  // straight free is sound; mv element types take the specialized
@@ -352,7 +354,7 @@ pub struct Buffer<T> {
352
354
  return self.cap
353
355
  }
354
356
 
355
- func grow = (ref self, int needed, out int: out >= needed) {
357
+ func grow = (ref self {}, int needed, out int: out >= needed) {
356
358
  if self.cap >= needed {
357
359
  return self.cap
358
360
  }
@@ -430,7 +432,7 @@ pub struct Buffer<T> {
430
432
  // value) — this is the primitive every container's `set` uses.
431
433
  // Internal: assumes a FRESH slot (see the contract comment). The public
432
434
  // write is `replace`, which is correct on fresh and occupied slots alike.
433
- internal inline func store = (ref self, int i: i >= 0 && i < self.cap, T val) {
435
+ internal inline func store = (ref self {}, int i: i >= 0 && i < self.cap, T val) {
434
436
  ```
435
437
  #arch: c
436
438
  ((T*)(unsigned long long)self->data)[i] = val;
@@ -490,7 +492,7 @@ pub struct Buffer<T> {
490
492
  // parameter is a pointer to the caller's storage — a `string`'s fat pair
491
493
  // arrives by value, so take-store would zero the callee's copy and leave
492
494
  // the caller's buffer shared).
493
- internal inline func store_take = (ref self, int i: i >= 0 && i < self.cap, T val) {
495
+ internal inline func store_take = (ref self {}, int i: i >= 0 && i < self.cap, T val) {
494
496
  ```
495
497
  #arch: c
496
498
  {
@@ -572,7 +574,7 @@ pub struct Buffer<T> {
572
574
  // the result is treated as OWNED by the borrow checker — the slot is
573
575
  // relinquished, so the caller is the sole remaining owner. The value
574
576
  // counterpart of ClassBuffer.move_int — used by List.pop for any value T.
575
- inline func move = (ref self, int i: i >= 0 && i < self.cap, mv out T) {
577
+ inline func move = (ref self {}, int i: i >= 0 && i < self.cap, mv out T) {
576
578
  ```
577
579
  #arch: c
578
580
  T* _slots = (T*)(unsigned long long)self->data;
@@ -652,7 +654,7 @@ pub struct Buffer<T> {
652
654
  // this raw form is correct for trivially-copyable elements only. NOT
653
655
  // `inline`: the body calls through the fn pointer, so splicing the raw
654
656
  // block into a caller would bypass the per-element specializations.
655
- func modify = (ref self, int i: i >= 0 && i < self.cap, func(T, out T) f) {
657
+ func modify = (ref self {}, int i: i >= 0 && i < self.cap, func(T, out T) f) {
656
658
  ```
657
659
  #arch: c
658
660
  ((T*)(unsigned long long)self->data)[i] = ((T (*)(void *, T))f->code)(f->env, ((T*)(unsigned long long)self->data)[i]);
@@ -739,7 +741,7 @@ pub struct Buffer<T> {
739
741
  // value, then deep-copies (strdup per string field). See
740
742
  // owning_buffer_specialize.ts (both backends). ClassBuffer.replace
741
743
  // destroys+frees class slots soundly.
742
- inline func replace = (ref self, int i: i >= 0 && i < self.cap, T val) {
744
+ inline func replace = (ref self {}, int i: i >= 0 && i < self.cap, T val) {
743
745
  ```
744
746
  #arch: c
745
747
  ((T*)(unsigned long long)self->data)[i] = val;
@@ -795,7 +797,7 @@ pub struct Buffer<T> {
795
797
  // cannot accept the `mv` keyword, so a borrow being transferred
796
798
  // (e.g. a loaded element) must go through here rather than be bound to
797
799
  // a freed local.
798
- pub func set = (ref self, int i: i >= 0 && i < self.cap, mv T value) {
800
+ pub func set = (ref self {}, int i: i >= 0 && i < self.cap, mv T value) {
799
801
  self.replace(i, value)
800
802
  }
801
803
 
@@ -810,7 +812,7 @@ pub struct Buffer<T> {
810
812
  // overwritten before it is read or destroyed again — Map.set_slot_ptr
811
813
  // (the probe-then-construct primitive) and the in-place `set` splice
812
814
  // are the callers, and both overwrite immediately.
813
- internal func destroy_at = (ref self, int i: i >= 0 && i < self.cap) {
815
+ internal func destroy_at = (ref self {}, int i: i >= 0 && i < self.cap) {
814
816
  ```
815
817
  #arch: c
816
818
  T* _slots = (T*)(unsigned long long)self->data;
@@ -854,7 +856,7 @@ pub struct Buffer<T> {
854
856
  // borrow-invalidation rules. Library-internal: the caller (the `List`
855
857
  // wrapper, or trusted internals) bounds-checks; the body is raw-only so
856
858
  // the missing-return net does not apply to the raw return.
857
- internal func slot_ptr = (ref self, int i, out ptr T) {
859
+ internal func slot_ptr = (ref self {}, int i, out ptr T) {
858
860
  ```
859
861
  #arch: c
860
862
  return (T*)(unsigned long long)self->data + i;
@@ -880,7 +882,7 @@ pub struct Buffer<T> {
880
882
  // owning_buffer_specialize.ts); this raw form is correct for
881
883
  // trivially-destructible elements only.
882
884
  inline func shift = (
883
- ref self,
885
+ ref self {},
884
886
  int dst: dst >= 0 && dst < self.cap,
885
887
  int src: src >= 0 && src < self.cap
886
888
  ) {
@@ -969,7 +971,7 @@ pub struct Buffer<T> {
969
971
  // carries mv elements' heap pointers with them — correct for every
970
972
  // element kind, raw for both backends (never names T).
971
973
  internal inline func move_range = (
972
- ref self,
974
+ ref self {},
973
975
  int dst: dst >= 0,
974
976
  int src: src >= dst,
975
977
  int count: count >= 0 && src + count <= self.cap
@@ -1045,7 +1047,7 @@ pub struct Buffer<T> {
1045
1047
  }
1046
1048
 
1047
1049
  // Internal: zeroes slots without reclaiming mv elements.
1048
- internal inline func zero = (ref self, int len) {
1050
+ internal inline func zero = (ref self {}, int len) {
1049
1051
  memset(self.data, 0, len * T_SIZE)
1050
1052
  }
1051
1053
 
@@ -1076,7 +1078,7 @@ pub struct Buffer<T> {
1076
1078
  return dst
1077
1079
  }
1078
1080
 
1079
- internal inline func store_or_int = (ref self, int i: i >= 0 && i < self.cap, int val) {
1081
+ internal inline func store_or_int = (ref self {}, int i: i >= 0 && i < self.cap, int val) {
1080
1082
  ```
1081
1083
  #arch: c
1082
1084
  ((long*)(unsigned long long)self->data)[i] |= val;
@@ -1092,7 +1094,7 @@ pub struct Buffer<T> {
1092
1094
  ```
1093
1095
  }
1094
1096
 
1095
- internal func alloc_float = (ref self, int size, out int: out >= size) {
1097
+ internal func alloc_float = (ref self {}, int size, out int: out >= size) {
1096
1098
  self.cap = size
1097
1099
  self.data = calloc(size, 8)
1098
1100
  return self.cap
@@ -1112,7 +1114,7 @@ pub struct Buffer<T> {
1112
1114
  ```
1113
1115
  }
1114
1116
 
1115
- internal inline func store_float = (ref self, int i: i >= 0 && i < self.cap, float val) {
1117
+ internal inline func store_float = (ref self {}, int i: i >= 0 && i < self.cap, float val) {
1116
1118
  ```
1117
1119
  #arch: c
1118
1120
  ((double*)(unsigned long long)self->data)[i] = val;
@@ -12,7 +12,7 @@ pub struct ClassBuffer<T> {
12
12
  // Publicly readable; grown only by ClassBuffer's own methods (`readonly`).
13
13
  readonly cap = 0
14
14
 
15
- internal func alloc_int = (ref self, int size, out int: out >= size) {
15
+ internal func alloc_int = (ref self {}, int size, out int: out >= size) {
16
16
  self.cap = size
17
17
  self.data = calloc(size, 8)
18
18
  return self.cap
@@ -25,11 +25,11 @@ pub struct ClassBuffer<T> {
25
25
  // element types to Buffer and class/trait elements to ClassBuffer
26
26
  // (monomorphize's field rewrite), so a call arriving HERE is always
27
27
  // pointer-sized: delegate to alloc_int.
28
- func alloc = (ref self, int size, out int: out >= size) {
28
+ func alloc = (ref self {}, int size, out int: out >= size) {
29
29
  return self.alloc_int(size)
30
30
  }
31
31
 
32
- internal func grow_int = (ref self, int needed, out int: out >= needed) {
32
+ internal func grow_int = (ref self {}, int needed, out int: out >= needed) {
33
33
  if self.cap >= needed {
34
34
  return self.cap
35
35
  }
@@ -65,7 +65,7 @@ pub struct ClassBuffer<T> {
65
65
  // handles, so the slot's CONTENT is the instance pointer: return the
66
66
  // stored word, not the slot's address. Library-internal: bounds are the
67
67
  // caller's obligation (the List wrapper constrains them).
68
- internal func slot_ptr = (ref self, int i, out ptr T) {
68
+ internal func slot_ptr = (ref self {}, int i, out ptr T) {
69
69
  ```
70
70
  #arch: c
71
71
  // The slot's address: through the alias, reads and writes hit the
@@ -89,7 +89,7 @@ pub struct ClassBuffer<T> {
89
89
  // (Buffer) or a class (ClassBuffer, after the Buffer<T> field is
90
90
  // rewritten). Bodies use 8-byte slots, matching _int.
91
91
 
92
- func grow = (ref self, int needed, out int: out >= needed) {
92
+ func grow = (ref self {}, int needed, out int: out >= needed) {
93
93
  if self.cap >= needed {
94
94
  return self.cap
95
95
  }
@@ -136,7 +136,7 @@ pub struct ClassBuffer<T> {
136
136
  // slot's previous occupant, so a second `store` at an occupied index
137
137
  // leaks that instance. Use replace (or replace_int) to overwrite a live
138
138
  // slot.
139
- internal inline func store = (ref self, int i: i >= 0 && i < self.cap, mv T val: val != 0) {
139
+ internal inline func store = (ref self {}, int i: i >= 0 && i < self.cap, mv T val: val != 0) {
140
140
  ```
141
141
  #arch: c
142
142
  ((long*)(unsigned long long)self->data)[i] = (long)val;
@@ -155,14 +155,14 @@ pub struct ClassBuffer<T> {
155
155
  // `fill`, and the buffer owns NOTHING — the slab keeps its real owner
156
156
  // (never grown, never freed by the view). Mirror of Buffer.init_view;
157
157
  // class slots are pointer words.
158
- internal func init_view = (ref self, uint64 slab, int fill: fill >= 0) {
158
+ internal func init_view = (ref self {}, uint64 slab, int fill: fill >= 0) {
159
159
  self.data = slab
160
160
  self.cap = fill
161
161
  }
162
162
 
163
163
  // Clear a view initialized by init_view (see Buffer.clear_view): the
164
164
  // holder's own field destroy then reclaims nothing.
165
- internal func clear_view = (ref self) {
165
+ internal func clear_view = (ref self {}) {
166
166
  self.data = 0
167
167
  self.cap = 0
168
168
  }
@@ -175,7 +175,7 @@ pub struct ClassBuffer<T> {
175
175
  // holder passes a ClassBuffer FIELD, never a local (a local owning buffer
176
176
  // is auto-destroyed at scope exit and would free the borrowed slab).
177
177
  internal func store_in_slab = (
178
- ref self,
178
+ ref self {},
179
179
  uint64 slab,
180
180
  int fill: fill >= 0,
181
181
  int slot: slot >= 0,
@@ -194,7 +194,7 @@ pub struct ClassBuffer<T> {
194
194
  // out of a ClassBuffer slot, or moving a value into a fresh mv
195
195
  // container — load returns a BORROW (the slot is unchanged) and storing
196
196
  // it elsewhere would create shared ownership (double-free at destroy).
197
- inline func move = (ref self, int i: i >= 0 && i < self.cap, mv out T) {
197
+ inline func move = (ref self {}, int i: i >= 0 && i < self.cap, mv out T) {
198
198
  ```
199
199
  #arch: c
200
200
  long *slots = (long*)(unsigned long long)self->data;
@@ -225,7 +225,7 @@ pub struct ClassBuffer<T> {
225
225
  // free). Storing the returned instance raw is sound: the slot takes
226
226
  // sole ownership and `f`'s return is not retained elsewhere. NOT
227
227
  // `inline`: the body calls through the fn pointer.
228
- func modify = (ref self, int i: i >= 0 && i < self.cap, func(T, out T) f) {
228
+ func modify = (ref self {}, int i: i >= 0 && i < self.cap, func(T, out T) f) {
229
229
  ```
230
230
  #arch: c
231
231
  long *slots = (long*)(unsigned long long)self->data;
@@ -258,7 +258,7 @@ pub struct ClassBuffer<T> {
258
258
  ```
259
259
  }
260
260
 
261
- internal inline func store_int = (ref self, int i: i >= 0 && i < self.cap, int val: val != 0) {
261
+ internal inline func store_int = (ref self {}, int i: i >= 0 && i < self.cap, int val: val != 0) {
262
262
  ```
263
263
  #arch: c
264
264
  ((long*)(unsigned long long)self->data)[i] = val;
@@ -272,7 +272,7 @@ pub struct ClassBuffer<T> {
272
272
  ```
273
273
  }
274
274
 
275
- internal inline func move_int = (ref self, int i: i >= 0 && i < self.cap, out int) {
275
+ internal inline func move_int = (ref self {}, int i: i >= 0 && i < self.cap, out int) {
276
276
  ```
277
277
  #arch: c
278
278
  long *slots = (long*)(unsigned long long)self->data;
@@ -292,7 +292,7 @@ pub struct ClassBuffer<T> {
292
292
 
293
293
  // Store into a slot, freeing the previous value (it is an owned class
294
294
  // pointer): run its destroy then free it before overwriting.
295
- internal func replace_int = (ref self, int i: i >= 0 && i < self.cap, int val: val != 0) {
295
+ internal func replace_int = (ref self {}, int i: i >= 0 && i < self.cap, int val: val != 0) {
296
296
  ```
297
297
  #arch: c
298
298
  long *slots = (long*)(unsigned long long)self->data;
@@ -329,7 +329,7 @@ pub struct ClassBuffer<T> {
329
329
  // replace path — the value-side sibling of `values.replace`) overwrites
330
330
  // the slot immediately afterwards. Contract: the slot must be
331
331
  // overwritten before it is read or destroyed again.
332
- internal func destroy_at = (ref self, int i: i >= 0 && i < self.cap) {
332
+ internal func destroy_at = (ref self {}, int i: i >= 0 && i < self.cap) {
333
333
  ```
334
334
  #arch: c
335
335
  long *slots = (long*)(unsigned long long)self->data;
@@ -362,7 +362,7 @@ pub struct ClassBuffer<T> {
362
362
  // preserves ownership for class elements.
363
363
  // Overwrite a live slot: destroy + free the displaced instance, then take
364
364
  // OWNERSHIP of `val` (`mv`) — same transfer rule as store.
365
- func replace = (ref self, int i: i >= 0 && i < self.cap, mv T val: val != 0) {
365
+ func replace = (ref self {}, int i: i >= 0 && i < self.cap, mv T val: val != 0) {
366
366
  ```
367
367
  #arch: c
368
368
  long *slots = (long*)(unsigned long long)self->data;
@@ -399,7 +399,7 @@ pub struct ClassBuffer<T> {
399
399
  // used by Map/Set.remove's backward-shift so shifting entries neither
400
400
  // duplicates nor orphans owned instances.
401
401
  func shift = (
402
- ref self,
402
+ ref self {},
403
403
  int dst: dst >= 0 && dst < self.cap,
404
404
  int src: src >= 0 && src < self.cap
405
405
  ) {
@@ -451,7 +451,7 @@ pub struct ClassBuffer<T> {
451
451
  // source slots the destination never covers — List.remove_at_or_panic's
452
452
  // whole-tail shift instead of per-element `shift` calls.
453
453
  internal inline func move_range = (
454
- ref self,
454
+ ref self {},
455
455
  int dst: dst >= 0,
456
456
  int src: src >= dst,
457
457
  int count: count >= 0 && src + count <= self.cap
@@ -281,7 +281,7 @@ pub mv struct Alert: Control {
281
281
  // An alert is a modal, not an in-window view: it measures to nothing and
282
282
  // the layout engine never frames it. The conformance exists so an Alert
283
283
  // can sit in a Control-typed slot without special-casing.
284
- pub func set_frame = (ref self, int x, int y, int width, int height) {
284
+ pub func set_frame = (ref self {}, int x, int y, int width, int height) {
285
285
  // No-op: modals are positioned by the window server.
286
286
  }
287
287
 
@@ -51,11 +51,11 @@
51
51
  pub trait App {
52
52
  // Called once before the window is shown, after the app is in its
53
53
  // final storage. Register layout roots here.
54
- func start = (ref self, ref Window win) {
54
+ func start = (ref self, ref Window win {}) {
55
55
  }
56
56
 
57
57
  // Called every frame until the window closes.
58
- func frame = (ref self, ref Window win, FrameEvents ev) {
58
+ func frame = (ref self, ref Window win {}, FrameEvents ev) {
59
59
  }
60
60
 
61
61
  // The per-frame event pump: drains every registered control event —
@@ -67,7 +67,7 @@ pub trait App {
67
67
  // in this one slot — the App contract never grows with the event
68
68
  // catalog. Conformers without registrations inherit this empty default
69
69
  // (trait defaults have precedent: `Enumerable.length`).
70
- func handle_events = (ref self, ref Window win) {
70
+ func handle_events = (ref self, ref Window win {}) {
71
71
  }
72
72
 
73
73
  // The up-call protocol (docs/HANDLERS.md Stage 3): a composite the app
@@ -76,7 +76,7 @@ pub trait App {
76
76
  // synthesized override, whose arms dispatch the id to the app's handler.
77
77
  // The borrow flows down per call; nothing outlives it. Default-empty,
78
78
  // like `handle_events`.
79
- func run_handler = (ref self, int id, ref Window win) {
79
+ func run_handler = (ref self, int id, ref Window win {}) {
80
80
  }
81
81
 
82
82
  // Close interception (the unsaved-changes pattern): run consults this
@@ -86,7 +86,7 @@ pub trait App {
86
86
  // close request consults again. Programmatic `win.close()` is FORCED
87
87
  // and bypasses this — handlers closing their own window never trip the
88
88
  // interception. Default: allow.
89
- func close_requested = (ref self, ref Window win, out bool) {
89
+ func close_requested = (ref self, ref Window win {}, out bool) {
90
90
  return true
91
91
  }
92
92
  }
@@ -99,7 +99,7 @@ pub mv struct Button: Control {
99
99
  ```
100
100
  }
101
101
 
102
- pub func set_frame = (ref self, int x, int y, int width, int height) {
102
+ pub func set_frame = (ref self {}, int x, int y, int width, int height) {
103
103
  ```
104
104
  #arch: c
105
105
  #platform: macos
@@ -85,7 +85,7 @@ pub mv struct CheckBox: Control {
85
85
  ```
86
86
  }
87
87
 
88
- pub func set_frame = (ref self, int x, int y, int width, int height) {
88
+ pub func set_frame = (ref self {}, int x, int y, int width, int height) {
89
89
  ```
90
90
  #arch: c
91
91
  #platform: macos
@@ -80,7 +80,7 @@ pub mv struct ColorPicker: Control {
80
80
  ```
81
81
  }
82
82
 
83
- pub func set_frame = (ref self, int x, int y, int width, int height) {
83
+ pub func set_frame = (ref self {}, int x, int y, int width, int height) {
84
84
  ```
85
85
  #arch: c
86
86
  #platform: macos
@@ -63,7 +63,7 @@ pub mv struct ComboBox: Control {
63
63
  ```
64
64
  }
65
65
 
66
- pub func set_frame = (ref self, int x, int y, int width, int height) {
66
+ pub func set_frame = (ref self {}, int x, int y, int width, int height) {
67
67
  ```
68
68
  #arch: c
69
69
  #platform: macos