Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Variables

Variable declarations are extremely simple. Simply pick a variable type and identifier, then set it to a value.

int x = 20;

Note

You cannot defined a variable with no value, for example: int x; is not valid syntax. However, variables are treated as mutable, so to achieve the same effect just initialize the variable with dummy data.

Currently the supported types in KSL are:

TypeIdentifierSize (Bits)
int8i88
int16i1616
int32i3232
int64i64 || int64
uint8u88
uint16u1616
uint32u3232
uint64u64 || uint64
float32f3232
floatf64 || float64
charchar8
boolbool1
voidvoidN|A
enumenum??
structstruct??

Note

You can make virtually any type an array by adding [] to the initialization type (e.g. int[] will create an int array.)

Note

Defining structs via the struct keyword will register an entierly new type to the type system, it can be treated like most other types, which means you can also make an array of structs using the struct name (e.g. my_struct[] will create an array of my_struct structs.)