LEVIATHAN v0.1 · in development

leviathan-lang.com / docs / reference

Language Reference

A precise specification of Leviathan as it is implemented today. Design rationale lives in the working spec; this reference documents syntax and behavior, category by category, with a runnable example for nearly every entity.

How to read this reference

  • planned marks a feature that is designed but not yet built.
  • engines notes appear where a feature runs on some compiler backends and not others. The four active engines are the tree-walk oracle, the IR interpreter, emit-C++, and LLVM (the primary AOT backend). A frozen pure x86-64/ELF backend is retained only as a differential-testing anchor and is never extended.
  • Code blocks are real Leviathan. Source files use the .lev extension; the compiler binary is leviathan and the build driver is trident.

The one idea behind everything

Most of what other languages treat as a special case, Leviathan treats as one general rule applied consistently:

A member is a typed slot bound to a label. A constructor is a method marked by a keyword. An operator is a method whose name is a symbol. A property is a typed view over a slot. Fields and methods aren't two kinds of thing — "method" just means the member's type is callable. Access, inheritance, collisions, interface requirements, and get/set views all follow from that single rule.

Three more principles recur throughout:

  • Resolution is by type, everywhere. Overloads, field access, operators, and assignment targets all resolve on type. A bare read with no type in context is the one thing that can't resolve — so it's an error, never a guess.
  • Honesty over hidden magic. A type annotation never secretly means something else. A function returning Promise<T> returns an actual promise; there is no implicit wrapping.
  • Gate the dangerous, guarantee the safe. Raw memory and interception live behind explicit markers so the safe majority keeps its guarantees.

Browse by category

Foundations

Declarations

Control & Errors

Standard Library

Toolchain

New to the language? The Learn Leviathan tutorial walks the same material as a guided narrative — start there, then use this reference to look up the details.