-
Notifications
You must be signed in to change notification settings - Fork 0
Functions
You can define functions in ccl.
The syntax for declaring a new function is as follows:
TypeName FunctionName() {
// function body here...
}
Functions can have arguments as well,
TypeName FunctionName(int arg0) {
// function body here...
}
Here is an example of a simple function named AddInts that adds two ints and returns the sum
// declaring the function
int AddInts(int a, int b) {
return a + b;
}
// Now lets use the function
int res = AddInts(1,2);
return res; // will return 3
Functions can have as many arguments as you could need, the limit on argument count theoretically is Int32.Max, but I dont suggest that you try that.
Function overloading is not allowed, multiple functions cannot have the same name, even if the signature is different. Every function name must be unique Functions do not allow default arguments (as of 1.2.1)
if a function doesn't return anything, it is declared using the keyword void
.
void SayHello() {
Log("Hello!");
}
void functions actually still do return an object, but that object is null
Functions do not support recursion, which means that a function cannot call itself. This feature will be added later, currently as of 1.2.1 variables are statically allocated.
Questions? Comments?
Contact me at kameron@creation-wasteland.com
Follow on Twitter: @wasteland_11
Copyright 2019 © Kameron Brooks