Update spec

This commit is contained in:
Nikita Lisitsa 2026-04-01 17:04:06 +03:00
parent d17f48cf7f
commit 07a50e5f7a

View file

@ -46,7 +46,7 @@ Literals:
123ul -> u64 123ul -> u64
3.14h -> f16 3.14h -> f16
3.14 -> f32 3.14 -> f32
3.14l -> f64 3.14d -> f64
'a' -> u8 (ascii only?) 'a' -> u8 (ascii only?)
'猫'u -> u32 '猫'u -> u32
@ -85,11 +85,11 @@ Logical (only bool type):
x || y // short-circuit x || y // short-circuit
x ^ y x ^ y
Equality (all built-in types, all pointer types, all array/struct types, only same type): Equality (all built-in types, all pointer types, all array/struct types, only same type unless integers):
x == y x == y
x != y x != y
Comparison (all built-in types, all pointer types, all array/struct types, only same type): Comparison (all built-in types, all pointer types, all array/struct types, only same type unless integers):
x < y x < y
x > y x > y
x <= y x <= y
@ -103,7 +103,7 @@ Bitwise (integer types, only same type):
x || y // short-circuit x || y // short-circuit
x ^ y x ^ y
Bitwise shift (any pair of integer types): Bitwise shift (any integer + any unsigned integer type):
x >> y x >> y
x << y x << y
@ -124,6 +124,7 @@ Pointer arithmetic works element-wise (like C or C++), i.e. p + n advances by n
Casting: Casting:
x as u32 // always explicit, no implicit casts allowed x as u32 // always explicit, no implicit casts allowed
The only implicit casting allowed is T mut* -> T* (maybe?)
Any integer/floating-point types can be cast to each other. Any integer/floating-point types can be cast to each other.
Any pointer types can be cast to each other (TODO: alignment? UB or safe fallback? Probably UB.) Any pointer types can be cast to each other (TODO: alignment? UB or safe fallback? Probably UB.)
@ -148,6 +149,7 @@ Flow control:
while condition: while condition:
statements statements
TODO: break/continue?
TODO: for loops? iterator/range interface? TODO: for loops? iterator/range interface?
======== STRUCTS ======== ======== STRUCTS ========
@ -167,6 +169,8 @@ Struct field access:
let p = &r let p = &r
let y = p.height // field access through pointer is the same let y = p.height // field access through pointer is the same
TODO: inner struct functions maybe? to act as namespace/module containers
======== FUNCTIONS ======== ======== FUNCTIONS ========
Function definition: Function definition:
@ -176,6 +180,10 @@ Function definition:
func bar(x: f32): // deduced return type unit func bar(x: f32): // deduced return type unit
print(x) print(x)
// External function: name taken literally as `powf`
// and C calling convention assumed
foreign func powf(x: f32, y: f32) -> f32 // no implementation
TODO: function overloading? Probably requires selecting a specific overload using `as` operator to save to a value (but not on call site) TODO: function overloading? Probably requires selecting a specific overload using `as` operator to save to a value (but not on call site)
======== TYPE OF TYPES ======== ======== TYPE OF TYPES ========