-
Notifications
You must be signed in to change notification settings - Fork 0
Language Guide
Learn the core AuroraScript syntax, module model, runtime values, and host-global declarations.
Applies to 4.0.0.
On this page
Every executable module begins with @module(NAME);. import consumes module exports and include combines source; paths are resolved by the host's Source Resolver rather than by scripts reading the file system directly.
// math.as
@module(MATH);
export func add(left, right) {
return left + right;
}
// main.as
@module(MAIN);
import math from "./math";
export func run() {
return math.add(20, 22);
}
Use var for mutable locals and const for bindings that are not reassigned. Functions can be passed as values and capture outer locals; cache repeatedly read properties in a local inside hot loops.
func makeAdder(base) {
return value => base + value;
}
var addTwenty = makeAdder(20);
return addTwenty(22); // 42
Ordinary objects suit flexible properties and Array suits heterogeneous collections. For known-length numeric loops, prefer Int32Array, Float64Array, Int8Array, or BooleanArray. Look up detailed members by object in the Script API Reference.
var profile = { name: "Aurora", enabled: true };
var scores = [20, 22];
scores.push(42);
return profile.name + ":" + scores.join(",");
Use throw new Error(message) for failures from which execution cannot continue; an expected “not found” result should usually return null or an agreed value. Use console.log and console.error for host-collected output.
func findPositive(values) {
var item = values.find(value => value > 0);
if (item == null) throw new Error("positive value is required");
console.log("found", item);
return item;
}
Names injected by the host through ScriptGlobal can be used directly in scripts. For editor diagnostics and completion, add a standalone @global(); declaration file visible to the Resolver; use declare const, declare var, or declare func, not export declare.
@global();
declare const APP_NAME;
declare func HOST_ADD(left, right);
- Host Integration: configure resolvers, domains, state, and CLR interop.
- Cookbook: complete small examples for common tasks.
- Performance and Benchmarks: hot-path patterns and reproducible measurement.
- TDoc Typed Document: a data format that preserves dates, packed arrays, paths, and registered CLR/CIL types.
AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License