Variables are identifiers for an area of memory of width defined by its type.
In simpler words, a variable is a container that can have a value in it. It has a data type, which specifies the kind of data it can contain, and that cannot change for the lifetime of the variable. There may not be two variables with the same name in the same scope.
[name] implements the following primitive data types:
i8, i16, i32, i64
u8, u16, u32, u64
f16 (half), f32 (float), f64 (double)
v While designing [name] i REALLY tried to avoid void pointers, because i HATE them. This is my attempt.
In addition to the primitive data types, the user can define custom data types (next page [HEY NILS MAYBE PUT A LINK HERE IDFK]), enums (a bit ahead) and generics (again, next page).
Also, modifiers can be added to change the data type entirely:
i64(f16, f16) may contain a function (or lambda, of course) that takes in two f16s and returns an i64.
In [name], variable declaration is done as such:
var pragmasopt type name;
Variables are automatically zeroed at declaration!
A variable can also be assigned a value at declaration time. In this case, the data type can be omitted and inferred by the compiler. Note that this may produce undesired results at times, so (especially in low level programming) be aware of data types.
The value may need code execution, in which case it is assigned 0 in memory and calculated when execution starts, before calling Main.
var pragmasopt typeopt name = value;
A variable can be defined constant, so that it can't change. In this case it requires a value, and:
const pragmasopt typeopt name = value;
var u64 myVar;
Declaring a variable of name myVar and type u64.
var myVar = 15;
Declaring a variable of name myVar and letting the compiler guess. In this particular case, the compiler will guess i64.
const u8 true = 1; const u8 false = 0;
Actual code in the bool library, defining true and false as "aliases" for 1 and 0
The default behaviour can be altered using pragmas:
(align X) aligns the area in memory by X bytes. Takes in any integer literal, including hex with the 0xX syntax
(nonzero) doesn't zero a local variable. This saves two instructions, specifically mov rXx, 0; mov %1, rXx where %1 is the variable. You might like to use this if you are genuinely insane
(static) makes a variable static. Like this, the value won't change between function calls. Basically, makes a function global without its identifier being all over the scopes. If you put this on a variable with a value definition, you might have brain damage. Keep in mind the declaration is ran every time the function is called. As such, it also does NOT zero the variables.