1.7 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	Plasma
The Plasma programming language.
Syntax Guide
Functions
All your logic must be contained in the "main" function, which looks like this:
main = Func(): Int {
}
This is how you define functions. In this example, "main" is the name of the function, and Int is the return type. My function takes no arguments.
If I wanted to make a function that takes arguments, it might look like this:
add = Func(number1: Int, number2: Int): Int {
	return number1 + number2
}
This is a function that adds two numbers together, here's the same function in Python:
def add(number1: int, number2: int) -> int:
	return number1 + number2
Calling Functions
To call a function, you type a dollar sign (the $ symbol), then the name of the function, and then you pass any of your arguments inbetween paranthesis, like this:
add = Func(number1: Int, number2: Int): Int {
	return number1 + number2
}
...
later in my code...
...
$add(9, 10);
Here's a "Hello, World!" program in Plasma:
main = Func(): Int {
	$print("Hello, World!\n");
}
print is a builtin function, it's defined in every piece of code you write. It has the same formatting as the printf function in C, so if I wanted to print an integer I could do it like so:
$print("%i\n", 123);
Variables
To create a variable, it's as simple as:
name: Type = value;
There are several types in Plasma, which are: Int, Float, Bool, String
Here's another example:
name: String = "bob";
age: Int = 23;
To change the value of an already defined variable, you just have to provide the name, and then write an equals sign, like this:
-- defining the variable
age: Int = 23;
-- changing it later
age = age + 1;
