Repository navigation
variables
A variable in Niv can be one of the following types:
VOID
I32
F32
BOOL
CHAR
STR
UTYPE // will be explained in a later chapter
LIST
NODE // only used for behind-the-scenes operations
RETURN // only used for behind-the-scenes operationsAll variables are type dynamic meaning they can change their type based on the value you set them to.
In order to access a variable's actual value in Niv, write $ followed by your variable's name (for example $myvar). This will tell Niv to look through the stack for your variable name and return its value if it exists.
usage example:
set name valArgs:
-
name:STR/CHAR -
value: Any value
Desc:
Creates a variable called the value of name (or overrides an existing one) and inserts the value of val into it.
Return value: The value of val.
For more complex examples check variables.nst
usage example:
release nameArgs:
-
name:STR
Desc:
Releases the given variable called name from memory and returns its value; crashes if the variable doesn't exist.
Return value: The value of the released variable.
For more complex examples check variables.nst
usage example:
resetDesc: Releases all variables in the program.
Return value: VOID.
For more complex examples check variables.nst