; We can have static arrays and have indexed access. ; let numbers: int[0xff] let numbers: int[0xff] set numbers[0] = 32 set numbers[1] = numbers[0] ; ; Arrays are syntactic sugar for pointers (@). ; let ptr:@u32 = numbers ; set ptr[10] = 33 ; ; Strings hold a .mem and .size fields with the number of bytes it holds. ; let hello: str = "hello world" ; set c[1] = 'a' ; "hallo world" ; ; fun foo(a: int): int { ; ; 1 ; ; } ; ; fun bar(): int { ; ; fun foo(): int 1 + 2 ; ; 1 ; ; } ; struct vec { ; x: f64 ; y: f64 ; huh: { ; z: int ; id: str ; } ; } ; let a = 1 ; match a { ; case 1 = "ha" ; case 2 = "ho" ; } ; cond { ; 1 == 1 = "ha" ; 2 != 2 = "ho" ; } ; ; struct vec { ; ; x: f64 ; ; y: f64 ; ; huh: { ; ; z: int ; ; id: str ; ; } ; ; } ; ; let v: vec = vec : { ; ; x = 10.0 ; ; huh = { ; ; z = 10 ; ; id = "blah" ; ; } ; ; } ; ; fun foo(): nil { ; ; struct vec { ; ; z: f64 ; ; } ; ; let a: vec ; ; set a.z = 1.0 ; ; } ; ; struct vec { ; ; x: f64 = 2.0 ; ; y: f64 = 1.0 ; ; bruh: { ; ; id: int = 10 ; ; msg: str = "hello" ; ; inner: { ; ; x: int = 32 ; ; y: str ; ; } ; ; } ; ; } ; ; let v: vec ; ; set v.x = 1.0 ; ; set v.bruh.id = 1 ; ; set v.bruh.inner.y = "yo" ; ; set v = vec : { ; ; x = 1.0 ; ; y = 32.0 ; ; ; bruh = dud : { ; ; ; id = 1 ; ; ; } ; ; } ; ; struct person { ; ; name: str = "joe" ; ; age: int = 18 * 2 ; ; } ; ; ; We can use the dot operator to access fields. ; ; let player_a: person ; ; set player_a.name = "alex" ; ; struct vec { ; ; x: f64 ; ; y: f64 ; ; z: f64 ; ; } ; ; let v = vec : { x = 1.0 } ; enum weekdays { ; mon = 1 ; tue ; wed ; thu ; fri ; sat ; sun ; } ; let d = weekdays.tue ; ; let b = a ; match 1 { ; case 2 = "monday" ; case 3 = "tuesday" ; else = "whateverday" ; } ; match d { ; case mon = "monday" ; case tue = "tuesday" ; else = "whateverday" ; } ; struct item { ; id: int ; name: str ; } ; ; let a: item = item { ; ; id = 1 ; ; } ; ; let a: item = item ; this shouldn't work, or should it return the default val? ; let c: item ; set c.id = 1 ; let d = c.id ; set a.name = "hello" ; let b = a.id ; let c = a.name ; fun add10(a: int, b: str): int { ; a + 10 ; } ; fun foo(): int { ; add10(1, "hello") ; } ; let a:f32 = (1.0 + 2.0 * 2.0) / 2.0 ; let annotated:int = (1 + 2 * 2) / 2 ; let numbers = 1 ; let symbols = numbers ; let arith = 1 + 2 * 4 ; let cmp = 1 <= 2 ; let logic = !true && false || (1 <= 2) ; let bits = 0xff & 0b00001111 ; let block = { ; let a = 1 + 2 ; a + 3 ; } ; let maybe = if (1 == 2) { ; 32 ; } else { ; 44 ; } ; let single = if (true) { ; 123 ; } ; while (!true) { ; "asjdflasdjf" ; } ; set single = 32 ; cond { ; 1 == 2 = "hello" ; else = "dong" ; } ; enum test { ; a = 1 ; b ; } ; ; Resolve struct accessors. ; struct my_struct { ; field_a: int ; field_b: int ; } ; let a:my_struct ; set a.field_a = 1 ; fun nested(): int { ; fun adder(a: u32, b: u32): u32 { ; a + b ; } ; if (1 + 1 == 2) { ; let b = 15 ; { ; let c = 32 ; 5 + c ; } ; } ; } ; enum field { ; a ; b ; } ; struct vec { ; a: int ; b: int ; } ; fun foo(): nil { ; bar() ; } ; fun bar(): nil { ; foo() ; } ; ; There are some builtint functions. ; println("hello world") ; ; Let/set. ; let num = 1 ; set num = 2 ; set num = 0 + num ; ; Loops and conditionals. ; if (num) 3 else 1 ; let val = if (2 + num == 4) num else num ; if (true) { ; let c = 1 ; 1 + 1 + c ; } ; fun testmatches(num: int): int { ; ; match (num) { ; ; case 1 = 23 ; ; case 2 = num ; ; else = num ; ; } ; cond { ; 1 == 1 = 23 ; 2 != 1 = num ; else = num ; } ; } ; while (num == 1) num ; while (true) { ; let c = 1 ; 1 + 1 + c ; } ; fun foo(a: int b: str): (f64, f64) { ; fun bar(): nil { ; println("ding") ; } ; if (a == 1) { ; ; return("test", b) ; return (3.0, 4.0) ; } ; return (1.0, 2.0) ; } ; let b = a ; let a = a ; set a = 10 ; set num = 1 << a ; baz() ; if (a) 1 ; if (num == 1) a ; if (num == 1) 1 else a