Examples · namespaces · 330 of 339
main
Namespaced modules: import "./file.tin" as name puts the file's types, functions, constants and agents under name., so two files may use the same names.
tin run examples/namespaces/main.tin// Namespaced modules: `import "./file.tin" as name` puts the file's types, functions,
// constants and agents under `name.`, so two files may use the same names.
//
// tin run examples/namespaces/main.tin
import "./arm.tin" as arm
import "./base.tin" as base
fn main() {
let joints = [
arm.Joint { name: "shoulder", angle: 1.2, limit: 1.6 },
arm.Joint { name: "elbow", angle: -2.4, limit: 2.1 },
]
print("arm over the limit: {arm.overLimit(joints)}")
print("elbow over: {joints[1].over()}")
let wheels: base.Joint[] = [base.Joint { name: "left", turns: 5 }, base.Joint { name: "right", turns: 1 }]
print("base over the limit: {base.overLimit(wheels)}")
print("reach is {arm.REACH} m")
// the model sees the tool as arm_canReach: tool names have no dots
print(arm.Planner("canReach 0.4"))
}