Modules
RGC uses import to load modules, and public to control visibility.
Importing modules
import geometry
import io
Defining a module
# geometry.rg
public def area(w: float, h: float) -> float {
return w * h
}
# items without public are only visible inside the module
def helper() { ... }
Using a module
import geometry
def main() {
print(geometry.area(3.0, 4.0))
}
Visibility
publicdeclarations (functions, types, constants) are visible outside.- Everything else is private by default, keeping implementation details inside module boundaries.
Standard library resolution
import foo searches:
foo.rgnext to the entry file (project modules can override the standard library)RGC_STD(colon-separated directory list)lib/andlib/rgc/up to 4 parent directories of the compiler executable/usr/local/lib/rgc,/usr/lib/rgc
json, regex, string, list, path, net, udp, http, tls, https, and gzip are source modules under lib/; io, time, random, and os are compiler-provided virtual modules with no source file and cannot be overridden. Circular imports are compile errors.