Syntax
Jiang syntax is organized around declarations, explicit types, and visible low-level operations. When reading a file, start with imports and top-level declarations, then move into statements and expressions inside function bodies.
Naming Style
Section titled “Naming Style”The project uses these conventions:
- Type names use
PascalCase. - Function names, variable names, field names, enum cases, and module aliases use
snake_case. - Primitive types such as
Int,Bool, andUInt8are written like ordinary type names.
Self is a special name in type position. self is available in instance methods and init bodies; functions without a self parameter do not have self.
Source Files
Section titled “Source Files”A source file is a sequence of top-level items:
importaliasconst- global declarations
- functions
struct,enum,traitextendcomptimeblocks
public marks a declaration as visible outside the module.
public const exports a compile-time value through the module interface. comptime { ... } evaluates a block before runtime;
conditional imports use namespace-valued aliases; see Const and Comptime.
Keyword Options
Section titled “Keyword Options”Some keywords can carry options. Jiang writes these options with square brackets after the keyword:
The old keyword(...) form is not used for keyword options. Parentheses remain ordinary expression
or type syntax, so keyword options stay visually separate from function calls.
Statements
Section titled “Statements”Blocks contain declarations, destructuring statements, assignments, call statements, control-flow statements, and defer.
Most statements end with semicolons. Control-flow forms that own a block, such as if, switch, while, and for, do not need an extra semicolon after the block.
Blocks
Section titled “Blocks”A block has a value only when it ends with a tail expression without a semicolon:
Without a tail expression, the block value is ().
Expressions
Section titled “Expressions”Jiang expressions include literals, names, calls, field access, indexing, slicing, arithmetic, comparisons, if, switch, try catch, and blocks.
Field literals are written with their type path:
Implicit Operation Layer
Section titled “Implicit Operation Layer”$ enters the implicit operation layer for a value or type:
Use parentheses when applying $ to a compound expression:
Prefer safe target-type initialization such as Float(value) for ordinary conversions. Do not use
value$.as(Type) as the everyday conversion spelling; it is a low-level cast form for raw pointers,
integer addresses, FFI, and similar code.
Patterns
Section titled “Patterns”is performs pattern matching. Optional values use .some(...):
Mutable payload bindings write the payload type explicitly:
switch uses the same style of patterns for optional, variant, and literal matches.
Characters and Strings
Section titled “Characters and Strings”Use single quotes for characters and double quotes for strings. There is no implicit conversion between them.
After escape decoding, a character must contain exactly one Unicode scalar: 'a', '中', '😀' and
'\0' are valid; '', 'abc' and 'e\u{301}' are not. The last example may look like one character,
but contains two scalars.
For custom languages using default tokens, single_quoted and double_quoted describe the quote form.
A language can interpret the complete single-quoted text itself. Creating a Jiang character literal
requires the single-scalar rule above.