Modules
Cyrus features a powerful module system with incremental compilation and a strong module cache. Modules allow code organization, reusability, and proper scoping.
Module Files
In Cyrus, files are considered modules.
Module files must:
- Use snake_case names
- Have the
.cyrusextension
Example: user_utils.cyrus defines a module named user_utils.
Inside user_utils.cyrus:
pub fn greet(name: str) {
printf("Hello, %s!\n", name);
}
Importing Modules
To use a module in another file, you import it.
import user_utils;
fn main() {
user_utils::greet("Cyrus");
}
Notes:
- The entry file (the one you compile as main) cannot import other modules; it is considered the root.
- Only publicly exported symbols (declared with pub) are visible outside their module.
Importing Single Symbols
You can import only a single symbol instead of the whole module:
import user_utils{greet};
fn main() {
greet("Alice"); // no need for module path prefix
}
Importing Multiple Modules
For convenience, Cyrus supports grouped imports:
import (
math_ops,
user_utils{greet}
);
fn main() {
var sum = math_ops::add(3, 5);
greet("Bob");
}
Renaming Imported Symbols
Renaming avoids conflicts or makes names clearer.
- Renaming a symbol
import user_utils{greet as greet_renamed};
fn main() {
greet_renamed("Charlie");
}
- Renaming a module
import math_ops as my_math;
fn main() {
var result = my_math::mul(4, 6);
}

