Skip to content
- The file passed to
brass run / brass build is the entry file.
- The entry file may contain top-level statements, which form the program’s
entry point. Alternatively it defines
fn main(). Having both is an error.
- Non-entry files (modules) may only contain declarations.
- Modules are files.
import compiler.lexer loads compiler/lexer.brass
relative to the entry file’s directory, so an import means the same thing
from every file. The module is then referred to by its last segment
(lexer.Token); there are no unqualified imports.
- Imports come first in a file. Cyclic imports are an error.
- Everything is private to its module unless marked
pub, struct fields
included: pub struct Url { pub host: Str path: Str }. Outside its
module a private field cannot be read or written, and a struct with any
private field cannot be built with Name { ... } or taken apart by a
pattern that names it; it is made by a function of its module, which can
check what goes in (“parse, don’t validate”). Enum variants are as
public as their enum.