Fahrenheit allows you to organize your code into packages and import them into other scripts.
To define a package, use the package keyword followed by the package name and a block containing the definitions.
package net.alantea.utils {
function log(msg) {
print("[LOG] " + msg);
}
structure Config {
host;
port;
}
}
Packages can be nested inside other packages.
package net {
package alantea {
package utils {
function log(msg) { print(msg); }
}
}
}
You can import other Fahrenheit files using the import statement.
Imports the file and namespaces its content under the alias.
import "utils.fh" as Utils;
Utils.log("Hello");
Executes the imported file in the current scope. This is useful for loading libraries that define packages or set up global state.
import "utils.fh";
net.alantea.utils.log("Hello");