Change to globals are PascalCase, locals are snake_case

This commit is contained in:
Krzosa Karol
2022-09-27 10:51:12 +02:00
parent 3dd9fae080
commit b8ab388bfc
11 changed files with 123 additions and 148 deletions

View File

@@ -15,15 +15,15 @@ main :: (): int
static_array: [8]int
// We can get size of array using length_of builtin
#assert(length_of(static_array) == 8)
#Assert(length_of(static_array) == 8)
// Accessing values is like in C
// Variables are zeroed by default
assert(static_array[1] == 0)
Assert(static_array[1] == 0)
element2 := static_array[2]
element0: int = static_array[0]
assert(element0 == 0 && element2 == 0)
Assert(element0 == 0 && element2 == 0)
// We can loop through arrays
// this implicitly defines 'it' variable
@@ -31,16 +31,16 @@ main :: (): int
*it = 1
// We set all variables to 1 so
assert(static_array[6] == 1)
Assert(static_array[6] == 1)
// This is how slice is defined, no [] index in between brackets
// slice is array pointer + length
// Other then that it works exactly like regular array
slice: []int = static_array
// We can't do a compile time assert anymore
assert(length_of(slice) == 8)
assert(slice[4] == 1)
// We can't do a compile time Assert anymore
Assert(length_of(slice) == 8)
Assert(slice[4] == 1)
// After we loop and reassign slice values
// old static_array gets changed
@@ -50,4 +50,4 @@ main :: (): int
// example in a single line
for slice;; *it = 2
assert(static_array[2] == 2)
Assert(static_array[2] == 2)