To include a file in iolite, use the 'import' keyword:
import "path/to/file";To import a C header, use the 'cimport' keyword, or 'climport' for a local c file:
cimport "stdio.h";
climport "my_header.h";To define a function, use the 'func' keyword:
func my_function(int arg1, string arg2) -> int {
// do stuff
}Broken down, it looks like this:
func <name>(<args>) -> <return type> {
<content>
}You can also define a function without a return type, which will fallback to void:
func my_function(int arg1, string arg2) {
// do stuff
}Another feature of functions which branches off of C is the ability to declare a function for later use, or presence in a header:
func my_function(int arg1, string arg2) -> int;To compare strings, use the 's==' and 's!=' operators:
if (my_string s== "hello") {
printf("Wow!\n");
}To define a function which is a member of a mocked-class, simply append the class name and a '.' separator to the function name:
func my_class.my_function() -> void {
// do stuff
}
// Call:
my_class.my_function();