Daslang 0.6 Reference Manual
Copyright (c) 2018-2026 Gaijin Entertainment
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- 1. Introduction
- 2. The language
- 2.1. Program Structure
- 2.2. Lexical Structure
- 2.3. Values and Data Types
- 2.3.1. Integer
- 2.3.2. Float
- 2.3.3. Bool
- 2.3.4. String
- 2.3.5. Type Conversion and Casting
- 2.3.6. Table
- 2.3.7. Array
- 2.3.8. Struct
- 2.3.9. Classes
- 2.3.10. Variant
- 2.3.11. Tuple
- 2.3.12. Enumeration
- 2.3.13. Bitfield
- 2.3.14. Function
- 2.3.15. Reference
- 2.3.16. Pointers
- 2.3.17. Smart Pointers
- 2.3.18. Iterators
- 2.4. Pointers
- 2.5. Constants, Enumerations, Global variables
- 2.6. Statements
- 2.6.1. Visibility Block
- 2.6.2. Control Flow Statements
- 2.6.3. Ranged Loops
- 2.6.4. break
- 2.6.5. continue
- 2.6.6. return
- 2.6.7. yield
- 2.6.8. pass
- 2.6.9. finally
- 2.6.10. Local Variable Declarations
- 2.6.11. assume
- 2.6.12. with
- 2.6.13. delete
- 2.6.14. Function Declaration
- 2.6.15. try/recover
- 2.6.16. panic
- 2.6.17. label and goto
- 2.6.18. Expression Statement
- 2.6.19. Global Variables
- 2.6.20. enum
- 2.6.21. typedef
- 2.7. Expressions
- 2.8. Function
- 2.8.1. Function declaration
- 2.8.2. OOP-style calls
- 2.8.3. Tail Recursion
- 2.8.4. Operator Overloading
- 2.8.5. Overloadable operators
- 2.8.6. Unary operators
- 2.8.7. Compound assignment operators
- 2.8.8. Index operators
- 2.8.9. Clone and finalize operators
- 2.8.10. is, as, and ?as operators
- 2.8.11. Null-coalesce operator
- 2.8.12. Struct method operators
- 2.8.13. Overloading the ‘.’ and ‘?.’ operators
- 2.8.14. Overloading accessors
- 2.9. Block
- 2.10. Lambda
- 2.11. Generator
- 2.12. Struct
- 2.13. Class
- 2.13.1. Member Visibility
- 2.13.2. Initializers
- 2.13.3. Calling Parent Methods
- 2.13.4. Runtime Type Checking (is)
- 2.13.5. Type Casting (as, ?as)
- 2.13.6. Class Templates
- 2.13.7. Static methods with
[class_method] - 2.13.8. Stack-Allocated Classes (using)
- 2.13.9. Complete Example
- 2.13.10. Implementation details
- 2.14. Tuple
- 2.15. Variant
- 2.16. Bitfield
- 2.17. Type Aliases
- 2.18. Array
- 2.19. Table
- 2.20. Iterator
- 2.21. Comprehension
- 2.22. String Builder
- 2.23. Modules
- 2.24. Move, Copy, and Clone
- 2.25. Clone
- 2.26. Finalizer
- 2.27. Temporary types
- 2.28. Unsafe
- 2.29. Generic Programming
- 2.30. Pattern matching
- 2.30.1. Enumeration Matching
- 2.30.2. Matching Variants
- 2.30.3. Declaring Variables in Patterns
- 2.30.4. Matching Structs
- 2.30.5. Using Guards
- 2.30.6. Tuple Matching
- 2.30.7. Matching Static Arrays
- 2.30.8. Dynamic Array Matching
- 2.30.9. Match Expressions
- 2.30.10. Matching with
|| - 2.30.11. [match_as_is] Structure Annotation
- 2.30.12. [match_copy] Structure Annotation
- 2.30.13. Static Matching
- 2.30.14. match_type
- 2.30.15. Multi-Match
- 2.31. Annotations
- 2.32. Options
- 2.33. Macros
- 2.33.1. Compilation passes
- 2.33.2. Invoking macros
- 2.33.3. AstFunctionAnnotation
- 2.33.4. AstBlockAnnotation
- 2.33.5. AstStructureAnnotation
- 2.33.6. AstEnumerationAnnotation
- 2.33.7. AstVariantMacro
- 2.33.8. AstReaderMacro
- 2.33.9. AstCallMacro
- 2.33.10. AstPassMacro
- 2.33.11. AstTypeMacro
- 2.33.12. AstTypeInfoMacro
- 2.33.13. AstForLoopMacro
- 2.33.14. AstCaptureMacro
- 2.33.15. AstCommentReader
- 2.33.16. AstSimulateMacro
- 2.33.17. AstVisitor
- 2.34. Reification
- 2.35. Built-in Functions
- 2.35.1. Invocation
- 2.35.2. Assertions
- 2.35.3. Debug
- 2.35.4. Panic
- 2.35.5. Memory & Type Utilities
- 2.35.6. Array Operations
- 2.35.7. Table Operations
- 2.35.8. Iterator Operations
- 2.35.9. Conversion Functions
- 2.35.10. Clone
- 2.35.11. Lock Operations
- 2.35.12. Serialization
- 2.35.13. Smart Pointer
- 2.35.14. Memory Mapping
- 2.35.15. Vector Construction
- 2.35.16. Move Helpers
- 2.35.17. Miscellaneous
- 3. The Runtime
- 3.1. Context
- 3.2. Locks
- 3.3. Type Mangling
- 3.3.1. Primitive types
- 3.3.2. Qualifiers and modifiers
- 3.3.3. Pointers
- 3.3.4. Composite prefixes
- 3.3.5. Container types
- 3.3.6. Fixed-size arrays (dim)
- 3.3.7. Callable types
- 3.3.8. Structures, handled types, and enumerations
- 3.3.9. Type aliases
- 3.3.10. Named arguments
- 3.3.11. Bitfields
- 3.3.12. Special / internal types
- 3.3.13. Remove-qualifiers (generics)
- 3.3.14. Interop function signatures
- 3.3.15. Querying mangled names at runtime
- 4. Embedding and Integration
- 4.1. Quick Start
- 4.2. C++ API Reference
- 4.3. C API Reference
- 4.3.1. When to use the C API
- 4.3.2. Initialization and shutdown
- 4.3.3. Text output
- 4.3.4. File access
- 4.3.5. Compilation
- 4.3.6. Simulation and context
- 4.3.7. Function evaluation
- 4.3.8. Argument helpers
- 4.3.9. Calling lambdas and blocks
- 4.3.10. Binding C functions
- 4.3.11. Binding types
- 4.3.12. String allocation
- 4.3.13. Context variables
- 4.3.14. Serialization
- 4.3.15. AOT checking
- 4.3.16. Module groups
- 4.3.17. Side effects
- 4.4. External Modules
- 4.4.1. Overview
- 4.4.2. Module types
- 4.4.3. The
.das_moduledescriptor - 4.4.4. Module resolution order
- 4.4.5. Building a C++ module
- 4.4.6. Building a pure daslang module
- 4.4.7. Using an external module from a host application
- 4.4.8. Installing external modules
- 4.4.9. Example: dascript-demo
- 4.4.10. In-tree modules vs external modules
- 4.5. Advanced Topics
- 5. Tutorials
- 5.1. Language Tutorials
- 5.1.1. Hello World
- 5.1.2. Variables and Types
- 5.1.3. Operators
- 5.1.4. Control Flow
- 5.1.5. Functions
- 5.1.6. Arrays
- 5.1.7. Strings
- 5.1.8. Structs
- 5.1.9. Enumerations and Bitfields
- 5.1.10. Tables
- 5.1.11. Tuples and Variants
- 5.1.12. Function Pointers
- 5.1.13. Blocks
- 5.1.14. Lambdas and Closures
- 5.1.15. Iterators and Generators
- 5.1.16. Modules and Program Structure
- 5.1.17. Move, Copy, and Clone
- 5.1.18. Classes and Inheritance
- 5.1.19. Generic Programming
- 5.1.20. Lifetime and Cleanup
- 5.1.21. Error Handling
- 5.1.22. Unsafe and Pointers
- 5.1.23. String Builder and Formatting
- 5.1.24. Pattern Matching
- 5.1.25. Annotations and Options
- 5.1.26. Contracts
- 5.1.27. Testing with dastest
- 5.1.28. LINQ — Language-Integrated Query
- 5.1.29. Functional Programming
- 5.1.30. JSON
- 5.1.31. Regular Expressions
- 5.1.32. Operator Overloading
- 5.1.33. Algorithm
- 5.1.34. Entity Component System (DECS)
- 5.1.35. Job Queue (jobque)
- 5.1.36. Pointers
- 5.1.37. Utility Patterns (defer + static_let)
- 5.1.38. Random Numbers
- 5.1.39. Dynamic Type Checking
- 5.1.40. Coroutines
- 5.1.41. Serialization (archive)
- 5.1.42. Testing Tools (faker + fuzzer)
- 5.1.43. Interfaces
- 5.1.44. Compiling and Running Programs at Runtime
- 5.1.45. Debug Agents
- 5.1.46. Cross-Context Services with apply_in_context
- 5.1.47. Data Walking with DapiDataWalker
- 5.1.48. Compile-Time Field Iteration with apply
- 5.1.49. Async / Await
- 5.1.50. Structure-of-Arrays (SOA)
- 5.2. C Integration Tutorials
- 5.2.1. C Integration: Hello World
- 5.2.2. C Integration: Calling daslang Functions
- 5.2.3. C Integration: Binding C Types
- 5.2.4. C Integration: Callbacks and Closures
- 5.2.5. C Integration: Unaligned ABI & Advanced
- 5.2.6. C Integration: Sandbox
- 5.2.7. C Integration: Context Variables
- 5.2.8. C Integration: Serialization
- 5.2.9. C Integration: AOT
- 5.2.10. C Integration: Threading
- 5.3. C++ Integration Tutorials
- 5.3.1. C++ Integration: Hello World
- 5.3.2. C++ Integration: Calling Functions
- 5.3.3. C++ Integration: Binding Functions
- 5.3.4. C++ Integration: Binding Types
- 5.3.5. C++ Integration: Binding Enumerations
- 5.3.6. C++ Integration: Low-Level Interop
- 5.3.7. C++ Integration: Callbacks
- 5.3.8. C++ Integration: Binding Methods
- 5.3.9. C++ Integration: Operators and Properties
- 5.3.10. C++ Integration: Custom Modules
- 5.3.11. C++ Integration: Context Variables
- 5.3.12. C++ Integration: Smart Pointers
- 5.3.13. C++ Integration: AOT Compilation
- 5.3.14. C++ Integration: Serialization
- 5.3.15. C++ Integration: Custom Annotations
- 5.3.16. C++ Integration: Sandbox
- 5.3.17. C++ Integration: Coroutines
- 5.3.18. C++ Integration: Dynamic Scripts
- 5.3.19. C++ Integration: Class Adapters
- 5.3.20. C++ Integration: Standalone Contexts
- 5.3.21. C++ Integration: Threading
- 5.4. Macro Tutorials
- 5.4.1. Macro Tutorial 1: Call Macros
- 5.4.2. Macro Tutorial 2: When Expression
- 5.4.3. Macro Tutorial 3: Function Macros
- 5.4.4. Macro Tutorial 4: Advanced Function Macros
- 5.4.5. Macro Tutorial 5: Tag Function Macros
- 5.4.6. Macro Tutorial 6: Structure Macros
- 5.4.7. Macro Tutorial 7: Block Macros
- 5.4.8. Macro Tutorial 8: Variant Macros
- 5.4.9. Macro Tutorial 9: For-Loop Macros
- 5.4.10. Macro Tutorial 10: Capture Macros
- 5.4.11. Macro Tutorial 11: Reader Macros
- 5.4.12. Macro Tutorial 12: Typeinfo Macros
- 5.4.13. Macro Tutorial 13: Enumeration Macros
- 5.4.14. Macro Tutorial 14: Pass Macro
- 5.4.15. Macro Tutorial 15: Type Macro
- 5.4.16. Macro Tutorial 16: Template Type Macro
- 5.4.17. Macro Tutorial 17: Quasi-quotation Reference
- 5.1. Language Tutorials