@tsonic/core 0.3.0 → 0.4.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 (2) hide show
  1. package/package.json +1 -1
  2. package/types.d.ts +48 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsonic/core",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Core type definitions for Tsonic - TypeScript to native compiler",
5
5
  "type": "module",
6
6
  "keywords": [
package/types.d.ts CHANGED
@@ -52,9 +52,54 @@ export type char = string; // System.Char (single UTF-16 code unit)
52
52
  // Erases to unknown for type safety - requires explicit handling
53
53
  export type ptr<T> = unknown;
54
54
 
55
- // NOTE: ref<T>, out<T>, In<T> have been removed.
56
- // Parameter modifiers will be expressed via syntax, not types.
57
- // See spec for forthcoming ref/out/in parameter syntax.
55
+ // ============================================================================
56
+ // Parameter Passing Modifiers
57
+ // ============================================================================
58
+
59
+ /**
60
+ * Marks a parameter as `out` - callee sets the value.
61
+ * Use with `as out<T>` at call sites.
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * import { int, out } from "@tsonic/core/types.js";
66
+ *
67
+ * let value: int = 0;
68
+ * dict.tryGetValue("key", value as out<int>);
69
+ * // value now contains the result
70
+ * ```
71
+ */
72
+ export type out<T> = T;
73
+
74
+ /**
75
+ * Marks a parameter as `ref` - callee can read and modify.
76
+ * Use with `as ref<T>` at call sites.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * import { int, ref } from "@tsonic/core/types.js";
81
+ *
82
+ * let count: int = 10;
83
+ * increment(count as ref<int>);
84
+ * // count is now modified
85
+ * ```
86
+ */
87
+ export type ref<T> = T;
88
+
89
+ /**
90
+ * Marks a parameter as `in` - read-only reference (optimization for large structs).
91
+ * Use with `as inref<T>` at call sites.
92
+ * Named `inref` because `in` is a TypeScript reserved keyword.
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * import { inref } from "@tsonic/core/types.js";
97
+ *
98
+ * const data: LargeStruct = { ... };
99
+ * process(data as inref<LargeStruct>);
100
+ * ```
101
+ */
102
+ export type inref<T> = T;
58
103
 
59
104
  // ============================================================================
60
105
  // Value Type Markers