📏 BASIC GRAMMAR

🔑 KEYWORDS

Keyword Description
and both X and Y are true
bool boolean type
char char type
class creates a class
const defines a constant
def defines a numeric constant
do tells that the loop will execute at least once, even if the condition evaluates to false
double double type
elif if the previous block of code evaluates to false, then executes another evaluation with a different statement
else runs the following block of code if the previous statement evaluates to false
exit exits from a loop
false false value
float float type
fun function
if introduces a conditional statement
import imports a module
int integer type
jump skips to the next iteration
let defines a variable
new instantiates an object
not negates a statement
or either X or Y is true
ret return a value or exit from a function
self refers to the current instance of an object
str string type
true true value
while defines a loop that will keep running as long as the condition is met

🔣 TYPES

Type annotation is optional. If left out, it will be automatically inferred.

Type Equivalent in C Description
str char[] string
char char single character
int int integer number
float float float number
double double double number
bool bool boolean value (true or false)

🔢 VARIABLES AND CONSTANTS

let defines a variable, a value that might be changed later. i.e.: let name = "Andrew" or let name:str = "Andrew". const defines a constant value. i.e.: const name = "Andrew" or const name:str = "Andrew".

If you don’t define a specific type, it will be automatically inferred and assigned. However, you might not be able to reassign a value of a different type later on elsewhere. If you do so, the compiler will throw a ERR_ASSIGN_VAL_OF_UNMATCHING_TYPE error. This is to ensure safety and reduce the likelihood of runtime errors.

One can also define a constant to hold a numeric value with #def. You don’t need the assign symbol.

🧲 FUNCTIONS

You can define a function and/or a procedure with the fun keyword followed by the name of the function. Functions can have return values and can receive arguments. They can also be called wherever in the code you need to call it.

#️⃣ RETURN VALUES

Functions can return values to be used elsewhere. One example is a function that calculates the Einstein’s formula E=m.c² and returns its result to be stored in a variable. They can return a value by using the ret keyword followed by the value you want to return. Optionally, you can define which type of value the function will return.