diff --git a/spec.txt b/spec.txt index 00c67ee..87227d8 100644 --- a/spec.txt +++ b/spec.txt @@ -11,8 +11,7 @@ Built-in types: i16 i32 i64 - f8 (maybe? cpu-emulated at best) - f16 (maybe? cpu-emulated at best) + f16 f32 f64 @@ -32,6 +31,7 @@ Array types: Function types: (arg1, arg2, arg3) -> result (arg1, arg2) -> unit // no return value + arg -> result // simplified syntax for single-argument case ======== LITERALS ======== @@ -45,16 +45,15 @@ Literals: 123l -> i64 123ul -> u64 3.14h -> f16 - 3.14f -> f32 - 3.14 -> f64 - 'a' -> u8 + 3.14 -> f32 + 3.14l -> f64 + 'a' -> u8 (ascii only?) '猫'u -> u32 -TODO: string literals? fixed-size arrays? built-in spans? +TODO: string literals? fixed-size arrays? built-in spans? Probably built-in spans (potentially defines in prelude.psl) "hello, world" -> utf-8 string "здарова, братки"u -> utf-32 string - ======== VARIABLES ======== Variable declaration: @@ -67,10 +66,13 @@ Variable declaration: Array declaration: let arr: i32[4] = [12, 15, 65, 42] - let arr: i32[] = [56, 23] // size inferred as 2 - maybe forbid this? let arr = [2, 5, 6] // size and type inferred as i32[3] + let arr: i32[0] = [] // need special empty array literal, type cannot be inferred -Variables must always be initialized. (TODO: really? What about arrays? Maybe need special syntax for zero-initialization or mass-initialization) +Null pointer literal: + let p: u32* = null // special like empty array literal, type cannot be inferred + +Variables must always be initialized. (TODO: really? What about arrays? Maybe need special syntax for zero-initialization or mass-initialization. Alternative: default to zero-initialization) Const variables must be initialized with a const expression (any expression that doesn't include non-const values). ======== OPERATORS ======== @@ -79,13 +81,15 @@ Logical (only bool type): !x x & y x | y + x && y // short-circuit + x || y // short-circuit x ^ y -Equality (all built-in types, only same type): +Equality (all built-in types, all struct types, only same type): x == y x != y -Comparison (all built-in types, only same type): +Comparison (all built-in types, all struct types, only same type): x < y x > y x <= y @@ -95,6 +99,8 @@ Bitwise (integer types, only same type): !x x & y x | y + x && y // short-circuit + x || y // short-circuit x ^ y Bitwise shift (any pair of integer types): @@ -119,7 +125,7 @@ Casting: x as u32 // always explicit, no implicit casts allowed 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?). +Any pointer types can be cast to each other (TODO: alignment? UB or safe fallback? Probably UB.) Address: &x // returns *T, fails if x is a const variable