Source files
Source files
A source file is a module. There is no separate module declaration for the common case; the file is the unit.
Entry point
A program starts at on_start in the main module. This is the same for every
kind of program, whether it is a command line tool or a windowed application:
fn on_start() {
// ...
}A UI application uses the same entry and hands control to the framework from there, by building an application and running it.
Statements and semicolons
Semicolons are optional. The standard library omits them almost everywhere, while some application code uses them consistently. Either parses. Match the file you are editing rather than mixing both styles inside one file.
let count: number = 0
let name: string = "peko";Comments
Three comment forms, and the distinction matters to tooling:
//! A module comment. Describes the file, and must appear at the top.
/// A doc comment. Attaches to the item that follows and shows up on hover.
fn size() => number {
// A plain comment. Ignored by tooling.
return 0
}Doc comments are what the language server shows on hover and what generated API documentation reads, so they belong on anything exported.
Naming
- Classes, traits, and enums are PascalCase.
- Functions, methods, variables, and fields are snake_case.
The compiler does not enforce this, but the standard library follows it.