The main function
Every Dime program begins with a main function that returns with the exit code.
function main(): int {
return 0
}
Every Dime program begins with a main function that returns with the exit code.
You can create functions with the function keyword.
Note: You may omit the return statement. Doing so will be the same as returning the null value of the data type such as
0,
falseor
'\x00'.
To declare a variable use the var keyword:
var name: type = value.
name = value.
You may 'shadow' variables.
Currently the following data types are implemented:
trueand
false
'A'
65
65.0
allocate(byteCount)
#"Hello world!"(UTF-8 encoded)
voidfor functions with no return value
For strings and bytes you can also use escapes such as
\nor
\x0A.
+ - / *
== != < > <= >=
&& ||
ptr->byte
ptr<-'A'
something = 0
i++
i--
'A'|>int
The condition of an if block can be any expression that evaluates to a boolean value.
While loop
For loop
Note: The head of a for loop is the only place where you have to use semicolons.
readByte(bool echo): byte
writeByte(byte b): void
writeBytes(pointer ptr, int byteCount): void
print(int number): void
print(float number): void
print(double number): void
allocate(int byteCount): pointer
free(pointer ptr): void
getConsoleWidth(): int
getConsoleHeight(): int
randomInt(int min, int max): int(min is inclusive and max is exclusive)