Reference
This page maps Yulang's top-level syntax, visibility, comments, and detailed reference topics. Use it to find a language construct; the guide presents the language in learning order.
Program structure
A Yulang program is a sequence of top-level statements. Statements are declarations (my, our, pub, struct, enum, act, role, impl, error, cast, type, use, mod) and bare expressions. The Playground evaluates bare expressions and shows the last root value; the CLI command yulang run --print-roots prints root expression values.
Visibility
| Keyword | Meaning |
|---|---|
my | Private binding, local or top-level |
our | Exports a binding into the enclosing companion module |
pub | Exports a binding from the module; also shows it in the Playground's Types pane |
Comments
yulang
// Line comment.
/* Block comment. */
-- Single-line doc comment (not a line comment).
---
Multi-line doc block.
May contain markdown and ```yulang fences.
---// and /* ... */ are ordinary comments. -- and --- blocks are documentation comments — they appear in syntax trees and tooling, so they are not interchangeable with //.
By topic
Surface syntax
- Syntax Style — when and how to drop parentheses
- Application & Operators — how
f x,f(x),f: x, andf.methoddiffer - Operator Declarations —
infix,prefix,suffix, precedence
Values and types
- Values & Types — the type universe
- Strings — string layout, escapes, interpolation
- Patterns — every pattern form
- Structs & Roles —
struct,with:,role,impl - Casts —
cast(x: A): B, where the compiler inserts them
Computation
- Functions — declarations, currying, named arguments
- Control Flow —
for,sub:,case, references - Effects —
act,catch, handler shapes - Errors —
error,fail,from,up,wrap
Style
- Idioms — what idiomatic Yulang looks like
Theory
- Type Inference Theory — what the inferer is doing under the hood
Standard library