Language guide
Table of contents
- Basic Syntax
- Functions
- Variables and Types
- Control Flow
- Type System
- Collections
- Error Handling
- Structures
- Methods
- Imports and Modules
- Advanced Features
- Standard Library
Basic syntax
Comments
Tolk uses traditional C-style comments:
// Single-line comment
/*
Multi-line comment
can span multiple lines
*/
Identifiers
Identifiers can start with [a-zA-Z$_]
and continue with [a-zA-Z0-9$_]
, like in most languages, camelCase preferred.
var justSomeVariable = 123;
Functions
Function declaration
fun
keyword with TypeScript-like syntax:
fun functionName(param1: type1, param2: type2): returnType {
// function body
}
Examples:
fun parseData(cs: slice): cell { }
fun loadStorage(): (cell, int) { }
fun main() { ... }
When return type omitted, it's auto-inferred.