SLeeLa language examples
This is the guided language-learning sequence. The foundational examples use syntax 1.7; the advanced examples use documented syntax 2.1 and the newest integer examples demonstrate syntax 2.7 and 2.8.
Start here
- CLASSIC Hello World — class, entry point, and
print. - ORIGINAL FizzBuzz — variables, loops, remainder, and decisions.
- USED methods — parameters, return values, and reuse.
- USED switch selection — multi-way branching.
- USED short-circuit guards — safe boolean expressions.
- NEW dynamic arrays — indexed data and append.
- NEW struct records — data aggregates.
- NEW nested classes — grouping related types.
- NEW native imports — calling library modules.
Advanced feature examples
| File | Feature |
|---|---|
| NEW-file-pipes | Pipe creation, worker thread, read/write, close, join |
| NEW-Synchro | Packet dispatch and honest latency/loss measurements |
| NEW-Munction | Composed local file-channel reach and receipt |
| NEW-Best-of | Weighted route selection using measured outcomes |
| NEW-struct-network-transport | Pack/unpack structs across loopback TCP |
| NEW-time-api | UTC, monotonic time, precision, HTTP date, JSON time |
| NEW-static-protected-access | Static protected members and controlled access |
Newest syntax examples
For the child-friendly lesson order, vocabulary, and exercises, see LEARNER-PATH.
Commands
See COMMANDS-and-workflow for the command overview. The option-by-option cookbook is indexed below; it follows man/man1/sleela.1 and the C++ command dispatcher.
Command-line examples
| Example | Coverage |
|---|---|
| CLI-01 | Global memory-manager flags and size suffixes |
| CLI-02 | Version, check, run, compile, artifact validation |
| CLI-03 | Multiple source inputs |
| CLI-04 | Native/exec, config, memory option, option terminator |
| CLI-05 | SleelaDoc topic/package/class lookup |
| CLI-06 | Documentation generation and live parsing |
| CLI-07 | Facade search and resource caps |
| CLI-08 | VM list/select/info/run |
| CLI-09 | Modium scan/status/restore |
| CLI-10 | Registry read/write/export |
| CLI-11 | XClass and JVM-family source modes |
| CLI-12 | Nordshrift emit/roundtrip/targets |
| CLI-13 | HTTP versions and server flags |
| CLI-14 | Seven design-activity axes |
| CLI-15 | Defender safety gates |
| CLI-16 | Environment variables and exit status |
These are documentation examples. Confirm each operation against the exact binary built on the target platform; server, VM, registry, and Defender actions may depend on configuration or have side effects.
Run
From the repository root, after building the runtime:
make -C impl
./impl/build/sleela check lib/examples/sleela/CLASSIC-hello-world.sleela
./impl/build/sleela run lib/examples/sleela/CLASSIC-hello-world.sleela
The authoritative supported syntax range is reported by sleela version and defined in impl/frontend/version.h. The repository's impl/README.md contains an older syntax-range note; prefer the compiler's version output and version.h.
Some examples in other subsystem folders are contract, policy, or simulation demonstrations. Their comments and the catalogue explain when they do not access hardware, external services, or an implemented native bridge.