Language guide
This guide is task-oriented: it shows the shape of the language and the rules you need while writing a package. The normative description, including every edge case, is the specification.
The model
Lingua Tungga compiles pure libraries. There is no main, no IO, no exceptions as control flow, and no shared mutable state. The host language owns effects and wiring.
- Values are immutable.
let mutmakes a local variable reassignable; fields, parameters, and collection elements never are. - Evaluation is eager and left to right.
&&and||short-circuit. - Nominal types. Two structs with identical fields are different types. Identity is the pair
(package, name). - One package, one host module. The package name, not the file name, determines the output module.
Read next
- Packages and files — package blocks, imports, visibility, naming.
- Types — primitives, collections,
Option,Result, structs, enums, generics. - Declarations — structs, enums, functions, receivers, bindings, tests.
- Expressions and statements —
match, loops, templates, tagged templates, JSX. - Errors —
?, traps, and what must stay in the host language. - Tests —
test,expect, and the conformance suite.
A complete package
package receiver {
export struct Counter {
value: Int
}
export fn bump(c: Counter) -> Counter {
Counter(value: c.value + 1)
}
test "calls as a function" {
expect.eq(bump(Counter(value: 1)), Counter(value: 2))
}
test "calls as a method" {
expect.eq(Counter(value: 1).bump(), Counter(value: 2))
}
}