3. The language
- 3.1. Program Structure
- 3.2. Lexical Structure
- 3.3. Values and Data Types
- 3.3.1. Integer
- 3.3.2. Float
- 3.3.3. Bool
- 3.3.4. String
- 3.3.5. Type Conversion and Casting
- 3.3.6. Table
- 3.3.7. Array
- 3.3.8. Struct
- 3.3.9. Classes
- 3.3.10. Variant
- 3.3.11. Tuple
- 3.3.12. Enumeration
- 3.3.13. Bitfield
- 3.3.14. Function
- 3.3.15. Reference
- 3.3.16. Pointers
- 3.3.17. Smart Pointers
- 3.3.18. Iterators
- 3.4. Pointers
- 3.5. Constants, Enumerations, Global variables
- 3.6. Statements
- 3.6.1. Visibility Block
- 3.6.2. Control Flow Statements
- 3.6.3. Ranged Loops
- 3.6.4. break
- 3.6.5. continue
- 3.6.6. return
- 3.6.7. yield
- 3.6.8. pass
- 3.6.9. finally
- 3.6.10. Local Variable Declarations
- 3.6.11. assume
- 3.6.12. with
- 3.6.13. delete
- 3.6.14. Function Declaration
- 3.6.15. try/recover
- 3.6.16. panic
- 3.6.17. label and goto
- 3.6.18. Expression Statement
- 3.6.19. Global Variables
- 3.6.20. enum
- 3.6.21. typedef
- 3.7. Expressions
- 3.7.1. Assignment
- 3.7.2. Operators
- 3.7.2.1. Arithmetic
- 3.7.2.2. Relational
- 3.7.2.3. Logical
- 3.7.2.4. Bitwise Operators
- 3.7.2.5. Pipe Operators
- 3.7.2.6. Interval Operator
- 3.7.2.7. Null-Coalescing Operator (??)
- 3.7.2.8. Ternary Operator (? :)
- 3.7.2.9. Null-Safe Navigation (?. and ?[)
- 3.7.2.10. Type Operators (is, as, ?as)
- 3.7.2.11. is type<T>
- 3.7.2.12. Cast, Upcast, and Reinterpret
- 3.7.2.13. Dereference
- 3.7.2.14. Address-of
- 3.7.2.15. Dot Operator Bypass
- 3.7.2.16. Safe Index (?[)
- 3.7.2.17. Unsafe Expression
- 3.7.2.18. Operators Precedence
- 3.7.3. Array Initializer
- 3.7.4. Struct, Class, and Handled Type Initializer
- 3.7.5. Tuple Initializer
- 3.7.6. Variant Initializer
- 3.7.7. Table Initializer
- 3.7.8. default and new
- 3.7.9. typeinfo
- 3.7.10. String Interpolation
- 3.8. Function
- 3.8.1. Function declaration
- 3.8.2. OOP-style calls
- 3.8.3. Tail Recursion
- 3.8.4. Operator Overloading
- 3.8.5. Overloadable operators
- 3.8.6. Unary operators
- 3.8.7. Compound assignment operators
- 3.8.8. Index operators
- 3.8.9. Clone and finalize operators
- 3.8.10. is, as, and ?as operators
- 3.8.11. Null-coalesce operator
- 3.8.12. Struct method operators
- 3.8.13. Overloading the ‘.’ and ‘?.’ operators
- 3.8.14. Overloading accessors
- 3.9. Block
- 3.10. Lambda
- 3.11. Generator
- 3.12. Struct
- 3.13. Class
- 3.13.1. Member Visibility
- 3.13.2. Initializers
- 3.13.3. Calling Parent Methods
- 3.13.4. Runtime Type Checking (is)
- 3.13.5. Type Casting (as, ?as)
- 3.13.6. Class Templates
- 3.13.7. Static methods with
[class_method] - 3.13.8. Stack-Allocated Classes (using)
- 3.13.9. Complete Example
- 3.13.10. Implementation details
- 3.14. Tuple
- 3.15. Variant
- 3.16. Bitfield
- 3.17. Type Aliases
- 3.18. Array
- 3.19. Table
- 3.20. Iterator
- 3.21. Comprehension
- 3.22. String Builder
- 3.23. Modules
- 3.24. Move, Copy, and Clone
- 3.25. Clone
- 3.26. Finalizer
- 3.27. Temporary types
- 3.28. Unsafe
- 3.29. Generic Programming
- 3.30. Pattern matching
- 3.30.1. Enumeration Matching
- 3.30.2. Matching Variants
- 3.30.3. Declaring Variables in Patterns
- 3.30.4. Matching Structs
- 3.30.5. Using Guards
- 3.30.6. Tuple Matching
- 3.30.7. Matching Static Arrays
- 3.30.8. Dynamic Array Matching
- 3.30.9. Match Expressions
- 3.30.10. Matching with
|| - 3.30.11. [match_as_is] Structure Annotation
- 3.30.12. [match_copy] Structure Annotation
- 3.30.13. Static Matching
- 3.30.14. match_type
- 3.30.15. Multi-Match
- 3.31. Annotations
- 3.32. Options
- 3.33. Macros
- 3.33.1. Compilation passes
- 3.33.2. Invoking macros
- 3.33.3. AstFunctionAnnotation
- 3.33.4. AstBlockAnnotation
- 3.33.5. AstStructureAnnotation
- 3.33.6. AstEnumerationAnnotation
- 3.33.7. AstVariantMacro
- 3.33.8. AstReaderMacro
- 3.33.9. AstCallMacro
- 3.33.10. AstPassMacro
- 3.33.11. AstTypeMacro
- 3.33.12. AstTypeInfoMacro
- 3.33.13. AstForLoopMacro
- 3.33.14. AstCaptureMacro
- 3.33.15. AstCommentReader
- 3.33.16. AstSimulateMacro
- 3.33.17. AstVisitor
- 3.34. Reification
- 3.35. AST Matching
- 3.35.1. Simple example
- 3.35.2. Macros
- 3.35.3. Tags
- 3.35.3.1. $e(var) — expression capture
- 3.35.3.2. $v(var) — value extraction
- 3.35.3.3. $i(var) — identifier name
- 3.35.3.4. $t(var) — type capture
- 3.35.3.5. $c(var) — call name capture
- 3.35.3.6. $f(var) — field name capture
- 3.35.3.7. $a(var) — remaining arguments
- 3.35.3.8. $b(var) — statement range capture
- 3.35.4. Wildcards
- 3.35.5. Type matching
- 3.35.6. Constant constructors and folding
- 3.35.7. Generic function matching
- 3.35.8. Result type
- 3.36. Built-in Functions
- 3.36.1. Invocation
- 3.36.2. Assertions
- 3.36.3. Debug
- 3.36.4. Panic
- 3.36.5. Memory & Type Utilities
- 3.36.6. Array Operations
- 3.36.7. Table Operations
- 3.36.8. Iterator Operations
- 3.36.9. Conversion Functions
- 3.36.10. Clone
- 3.36.11. Lock Operations
- 3.36.12. Serialization
- 3.36.13. Smart Pointer
- 3.36.14. Memory Mapping
- 3.36.15. Vector Construction
- 3.36.16. Move Helpers
- 3.36.17. Miscellaneous
- 3.37. Lint Tools
- 3.37.1. Quick start
- 3.37.2. Standalone utility
- 3.37.3. Suppressing specific warnings
- 3.37.4. Important notes
- 3.37.5. Paranoid rules
- 3.37.5.1. LINT001 — unreachable code
- 3.37.5.2. LINT002 — unused variable
- 3.37.5.3. LINT003 — variable can be
let - 3.37.5.4. LINT004 — underscore-prefixed variable is used
- 3.37.5.5. LINT005 — redundant
reinterpretcast - 3.37.5.6. LINT006 — division by zero (constant zero divisor)
- 3.37.5.7. LINT007 — identical left and right operands
- 3.37.5.8. LINT008 — both ternary branches equivalent
- 3.37.5.9. LINT009 —
thenbranch equivalent toelsebranch
- 3.37.6. Performance rules
- 3.37.6.1. PERF001 — string
+=in loop - 3.37.6.2. PERF002 —
character_atin loop with loop variable - 3.37.6.3. PERF003 —
character_atanywhere - 3.37.6.4. PERF004 — string interpolation reassignment in loop
- 3.37.6.5. PERF005 —
length(string)in while condition - 3.37.6.6. PERF006 —
push/emplacein loop withoutreserve() - 3.37.6.7. PERF007 — unnecessary
string(das_string)in comparison - 3.37.6.8. PERF008 — unnecessary
get_ptr()foris/as - 3.37.6.9. PERF009 — redundant move-init variable immediately returned
- 3.37.6.10. PERF010 — unnecessary
get_ptr()for null comparison - 3.37.6.11. PERF011 — unnecessary
get_ptr()for field access - 3.37.6.12. PERF012 —
string(das_string)passed to strings function - 3.37.6.13. PERF013 —
a += 1/a -= 1should bea++/a-- - 3.37.6.14. PERF014 — closed-interval char-class range check
- 3.37.6.15. PERF015 — ternary min / max
- 3.37.6.16. PERF016 — ternary abs
- 3.37.6.17. PERF017 —
length(s) == 0should beempty(s) - 3.37.6.18. PERF018 —
for (i in range(length(arr)))should iterate directly
- 3.37.6.1. PERF001 — string
- 3.37.7. Style rules
- 3.37.7.1. STYLE001 — unnecessary
<|pipe before block argument - 3.37.7.2. STYLE002 —
<|pipe before parameterless block - 3.37.7.3. STYLE003 — redundant
$()on parameterless block - 3.37.7.4. STYLE005 — braces around a single-statement early exit
- 3.37.7.5. STYLE006 —
string(__rtti)comparison should useis - 3.37.7.6. STYLE010 —
if (true)should be a bare block - 3.37.7.7. STYLE011 — variable declaration followed by immediate assignment
- 3.37.7.8. STYLE012 —
array<T>initialized by a run ofpush/emplace - 3.37.7.9. STYLE014 — comment block exceeds 3 lines at module/public scope
- 3.37.7.10. STYLE015 — comment block exceeds 1 line inside a
def private - 3.37.7.11. STYLE016 — adjacent guards leading to identical early-exit
- 3.37.7.12. STYLE017 —
if (cond) return true; else return falseshould bereturn cond - 3.37.7.13. STYLE018 — redundant boolean comparison
- 3.37.7.14. STYLE019 — nested
min(max(...))should beclamp(...) - 3.37.7.15. STYLE020 — scalar
from_JVshould bev ?? defV - 3.37.7.16. STYLE021 — repeated
table<string; JsonValue?>inserts → named-tupleJV
- 3.37.7.1. STYLE001 — unnecessary
- 3.37.8. Tests
4. The Runtime
- 4.1. Context
- 4.2. Locks
- 4.3. Very safe context
- 4.4. Type Mangling
- 4.4.1. Primitive types
- 4.4.2. Qualifiers and modifiers
- 4.4.3. Pointers
- 4.4.4. Composite prefixes
- 4.4.5. Container types
- 4.4.6. Fixed-size arrays (dim)
- 4.4.7. Callable types
- 4.4.8. Structures, handled types, and enumerations
- 4.4.9. Type aliases
- 4.4.10. Named arguments
- 4.4.11. Bitfields
- 4.4.12. Special / internal types
- 4.4.13. Remove-qualifiers (generics)
- 4.4.14. Interop function signatures
- 4.4.15. Querying mangled names at runtime