The #module_parameters
directive can be used to declare parameters that the user can be set when importing a module. Default values can be provided so that the user does not have to know about these parameters in order to import.
When creating a module
, you can use #module_parameters
to create user parameters that can be set by the user. Let’s create a module called module.jai
in a folder called Module
.
#module_parameter(VERBOSE := false);
#run {
if VERBOSE {
print("The module is in VERBOSE mode\n");
} else {
print("The module is in NON_VERBOSE mode\n");
}
}
In your main.jai
, you can import the Module
using jai main.jai -import_dir Module
.
#import "Module" (VERBOSE=true);
main :: () {
}