importAs
importAs("module", "alias") loads a module exactly like import, but binds it under a name you choose instead of the module's own name.
Syntax
global setup(){
importAs("math", "m");
importAs("network", "net");
importAs("json.so", "nativeJson"); // a native library under an alias
}
global main(){
println(global.m.sqrt(9.0)); // 3
}
Rules
- Both arguments are string literals. An expression is rejected with
expected module path string. - The alias is used as
global.<alias>, soimportAs("math", "m")is reached asglobal.m.<name>(...). - Like
import, it is a statement and may appear in any function body, not only insetup(). - Stdlib
.lynxwrappers useimportAs("name.so", "nativeName")internally, then expose typedglobal f(...) -> T { ... }forwards; that is how a module wraps a native backend.
See also
- modules — the search order, resolution, and compiled- executable behaviour.