World Peace
A small but funny complete no-types programming language. If static typing and function programming arguments create so much flamewars, then what will lead to world peace? This. It has a REPL, source runner, image compiler, module loading, examples, tests, and (janky) editor support.
We take inspiration from some niche and less niche things.
| Part | Details |
|---|
| Values | 64-bit numbers and nested numeric arrays. Strings are byte arrays by convention. |
| Functions | dec declarations, --- body lines, and end return clauses. |
| Patterns | Exact values, ranges, wildcard arms, array prefixes, array suffixes, and parameter filters. |
| Modules | load support; resolves a local module. |
| Commands | peace repl, peace run FILE.wp, peace compile FILE.wp -o OUTPUT. |
Case patterns
Matches empty arrays, array starts, array ends, and a fallback arm.
dec array_tag(num values):
--- num tag = 0;
--- case {
--- values <- []: tag = 69,
--- values <- [1, 2, ..]: tag = 83,
--- values <- [.., 9]: tag = 57,
--- _: tag = 63,
--- }
end {
tag
}
Parameter filters
A function can split cases by exact argument values or by array slices.
// exact-value filters
dec fibonacci(num[=0] n):
end {
0
}
dec fibonacci(num[=1] n):
end {
1
}
| Task | Command |
|---|
| Run a tour file | nix run .# -- run examples/tour/01-hello.wp |
| Start the REPL | nix run .# -- repl |
| Compile an executable | ./peace compile examples/tour/01-hello.wp -o /tmp/world-peace-hello |