@@ -30,12 +30,15 @@ Ovum is a strongly statically typed, single-threaded language focused on safety,
3030
3131---
3232
33- ## [ Types and Nullability] ( docs/reference/types .md )
33+ ## [ Types] ( docs/reference/types.md ) and [ Nullability] ( docs/reference/nullable .md )
3434
35- - Nullable types: append ` ? ` (e.g., ` Int? ` ).
36- - Safe call ` ?. ` , Elvis ` ?: ` , non‑null ` !! ` .
37- - Type test ` is ` , cast ` as ` (downcast yields nullable type).
38- - Explicit cast to ` Bool ` allowed for any value.
35+ - ** Fundamental types** : ` int ` , ` float ` , ` byte ` , ` char ` , ` bool ` , ` pointer ` (value types, not nullable, not Objects)
36+ - ** Primitive reference types** : ` Int ` , ` Float ` , ` Byte ` , ` Char ` , ` Bool ` , ` Pointer ` (reference wrappers, nullable, Objects)
37+ - ** Implicit conversion** : Literals convert to primitives (` val count: Int = 0 ` )
38+ - ** Nullable types** : Append ` ? ` to reference types only (e.g., ` Int? ` , ` String? ` )
39+ - ** Safe call ` ?. ` ** , ** Elvis ` ?: ` ** for null handling
40+ - ** Type test ` is ` ** , ** cast ` as ` ** (downcast yields nullable type)
41+ - ** Copy assignment ` := ` ** for deep copying reference types
3942
4043---
4144
@@ -51,9 +54,9 @@ Ovum is a strongly statically typed, single-threaded language focused on safety,
5154- Arithmetic: ` + - * / % `
5255- Comparison: ` == != < <= > >= `
5356- Boolean: ` && || ! xor ` (short‑circuit ` && ` /` || ` ).
54- - Assignment: ` = `
57+ - Assignment: ` = ` (reference assignment), ` := ` (copy assignment)
5558- Member/calls: ` . () ` and safe ` ?. `
56- - Null handling: ` ?. ?: !! `
59+ - Null handling: ` ?. ?: `
5760- Type ops: ` as ` , ` is `
5861- Namespace: ` :: `
5962
@@ -77,7 +80,7 @@ Ovum is a strongly statically typed, single-threaded language focused on safety,
7780- Pipeline: ` .ovum ` → bytecode → Ovum VM.
7881- GC for memory safety; JIT compiles hot paths.
7982- Single‑threaded execution model.
80- - Architectures: amd64, arm64. Numeric widths: ` Int ` 8 bytes, ` Float ` 8 bytes.
83+ - Architectures: amd64, arm64. Numeric widths: ` int ` 8 bytes, ` float ` 8 bytes.
8184- Entry point: ` Main(args: StringArray): Int ` .
8285
8386Build & Run (conceptual): write ` .ovum ` , compile (parse, type‑check, enforce const/pure), run on VM (JIT + GC).
@@ -98,7 +101,7 @@ Build & Run (conceptual): write `.ovum`, compile (parse, type‑check, enforce c
98101
99102Only inside ` unsafe { ... } ` :
100103- Global ` var ` and ` static var ` writes.
101- - Const/mutable casts; ` Pointer ` , address‑of, dereference.
104+ - Const/mutable casts; ` pointer ` , address‑of, dereference.
102105- Manual destructor calls.
103106- ` sys::Interope ` ; casting any value to (const or mutable) ` ByteArray ` .
104107
@@ -111,35 +114,40 @@ Only inside `unsafe { ... }`:
111114``` ovum
112115// .ovum file
113116fun Main(args: StringArray): Int {
114- val count: Int = args.Length()
117+ val count: Int = args.Length() // Built-in returns Int
115118 sys::Print("Args count: " + count.ToString())
116- return 0
119+ return 0 // Implicit conversion from literal
117120}
118121```
119122
120123### Pure functions with caching
121124
122125``` ovum
123- pure fun Fib(n: Int ): Int {
126+ pure fun Fib(n: int ): int {
124127 if (n <= 1) return n
125- return Fib(n - 1) + Fib(n - 2)
128+ val fib1: int = Fib(n - 1)
129+ val fib2: int = Fib(n - 2)
130+ return fib1 + fib2
126131}
127132```
128133
129- ### ` is ` , ` as ` , ` !! ` and ByteArray casts
134+ ### ` is ` , ` as ` and ByteArray casts
130135
131136``` ovum
132137fun DemoCasts(obj: Object): Void {
133138 if (obj is Point) {
134- val p: Point = (obj as Point)!! // nullable cast + assert
135- sys::Print(p.ToString())
139+ val p: Point? = obj as Point
140+ if (p != null) {
141+ val nonNullP: Point = p ?: Point(0, 0) // Use Elvis operator
142+ sys::Print(nonNullP.ToString())
143+ }
136144 }
137145
138146 // Bool cast
139- val b1: Bool = ( 0 as Bool) // false
140- val b2: Bool = ( 42 as Bool) // true
141- val b3: Bool = ( obj as Bool) // always true
142- val b4: Bool = (( obj as Point) as Bool) // true if obj is a Point
147+ val b1: Bool = 0 as bool // false
148+ val b2: Bool = 42 as bool // true
149+ val b3: Bool = obj as bool // always true
150+ val b4: Bool = (obj as Point) as bool // true if obj is a Point
143151
144152 // Unsafe: raw byte views
145153 unsafe {
@@ -170,11 +178,14 @@ class DefinedFunctional {
170178}
171179
172180val AddNullable: CustomFunctional = pure fun(a: Int?, b: Int?): Int {
173- return (a ?: 0) + (b ?: 0)
181+ val aVal: int = a ?: 0 // Implicit conversion from Int? to int
182+ val bVal: int = b ?: 0
183+ return Int(aVal + bVal) // Implicit conversion from int to Int
174184}
175185
176186fun Main(args: StringArray): Int {
177- return AddNullable(2, DefinedFunctional(-1)(2))
187+ // Constructor call then functional call via `call`
188+ return AddNullable(2, DefinedFunctional(-1)(2)) // Implicit conversion from literals
178189}
179190```
180191
@@ -198,29 +209,30 @@ class Multiplier implements ICalculator {
198209 }
199210}
200211
201- pure fun ProcessNumbers(calc: ICalculator, numbers: IntArray): Int {
202- var result: Int = 0
212+ pure fun ProcessNumbers(calc: ICalculator, numbers: IntArray): int {
213+ var result: int = 0
203214 for (num in numbers) {
204- result = result + calc.Calculate(num, 2)
215+ val calcResult: Int = calc.Calculate(num, 2) // Implicit conversion from literal
216+ result = result + calcResult // Implicit conversion
205217 }
206218 return result
207219}
208220
209- fun Main(args: StringArray): Int {
221+ fun Main(args: StringArray): int {
210222 val numbers: IntArray = IntArray(3)
211- numbers[0] = 5
212- numbers[1] = 10
213- numbers[2] = 15
223+ numbers[0] : = 5 // Implicit conversion from literal
224+ numbers[1] : = 10
225+ numbers[2] : = 15
214226
215227 val adder: ICalculator = Adder()
216228 val multiplier: ICalculator = Multiplier()
217229
218- val sumResult: Int = ProcessNumbers(adder, numbers)
219- val productResult: Int = ProcessNumbers(multiplier, numbers)
230+ val sumResult: int = ProcessNumbers(adder, numbers)
231+ val productResult: int = ProcessNumbers(multiplier, numbers)
220232
221- sys::Print("Sum result: " + sumResult.ToString())
222- sys::Print("Product result: " + productResult.ToString())
233+ sys::Print("Sum result: " + Int( sumResult) .ToString())
234+ sys::Print("Product result: " + Int( productResult) .ToString())
223235
224- return 0
236+ return 0 // Implicit conversion from literal
225237}
226238```
0 commit comments