For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
Mojo language reference
Welcome to the Mojo language reference. This documentation provides a concise reference for Mojo's syntax—identifiers, keywords, literals, expressions, operators, statements, function declarations, and more. It's organized by grammar construct and is designed for quick lookup when you need the exact rules, precedence, or form of a specific language element.
Identifiers & keywords
Naming rules, reserved words, escaped identifiers, and argument conventions
Literals
Integer, floating-point, string, t-string, boolean, None, and Self literals
Numeric types
SIMD, DType, Scalar, Int, UInt, integers, floating-point, Byte, literals, and conversions
Operators
Operator precedence, associativity, and implementing operators for custom types
Expressions
Tuples, collection displays, member access, calls, subscripts, ternary conditionals, and comprehensions
Simple statements
Imports, assignments, return, raise, break, continue, and compile-time declarations
Compound statements
If statements, loops, error handling with try/except, context managers, and compile-time control flow
Function declarations
Signatures, parameters, arguments, default values, constraints, effects, and special methods
Struct declarations
Fields, methods, initializers, destructors, and trait conformance for structs
Trait declarations
Required and provided methods, associated types, trait inheritance, trait composition, and conformance
Inline MLIR
Inline MLIR built-ins can call operations that the language doesn't expose natively.
Decorators
Modify or extend the behavior of a struct, function, or other declaration at compile time.