Daslang 0.6.2 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. Design Philosophy
- 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.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.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
- 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
- 5. Embedding and Integration
- 5.1. Quick Start
- 5.2. C++ API Reference
- 5.3. C API Reference
- 5.3.1. When to use the C API
- 5.3.2. Initialization and shutdown
- 5.3.3. Text output
- 5.3.4. File access
- 5.3.5. Compilation
- 5.3.6. Simulation and context
- 5.3.7. Function evaluation
- 5.3.8. Argument helpers
- 5.3.9. Calling lambdas and blocks
- 5.3.10. Binding C functions
- 5.3.11. Binding types
- 5.3.12. String allocation
- 5.3.13. Context variables
- 5.3.14. Type introspection
- 5.3.15. Serialization
- 5.3.16. AOT checking
- 5.3.17. Module groups
- 5.3.18. Side effects
- 5.4. External Modules
- 5.4.1. Overview
- 5.4.2. Module types
- 5.4.3. The
.das_moduledescriptor - 5.4.4. Module resolution order
- 5.4.5. Building a C++ module
- 5.4.6. Building a pure daslang module
- 5.4.7. Using an external module from a host application
- 5.4.8. Installing external modules
- 5.4.9. Example: dascript-demo
- 5.4.10. In-tree modules vs external modules
- 5.5. Project Files (.das_project)
- 5.6. Advanced Topics
- 6. Utils
- 6.1. daslang-live — Live-Reload Application Host
- 6.2. dastest — Test Framework
- 6.3. dascov — Code Coverage
- 6.4. daspkg — Package Manager
- 6.4.1. Quick start
- 6.4.2. Why daspkg?
- 6.4.3. Commands
- 6.4.4. Package sources
- 6.4.5. The
.das_packagemanifest - 6.4.6. Install flow
- 6.4.7. Global modules
- 6.4.8. Project layout
- 6.4.9. Lock file
- 6.4.10. Package index
- 6.4.11. Use-case examples
- 6.4.12. Version model
- 6.4.13. Requirements
- 6.4.14. Architecture
- 6.5. MCP Server — AI Tool Integration
- 6.6. detect-dupe — Cross-file similar-function detector
- 6.7. find_dupe — AI judge for detect-dupe clusters
- 6.8. Profiler — Runtime Profiling
- 6.9. Memory Leak Detection — Diagnostics Cheat Sheet
- 6.9.1. At a glance
- 6.9.2. Picking the right tool
- 6.9.3. 1. daslang leak profiler (
--das-profiler-leaks) - 6.9.4. 2. C++ heap report (
-track-allocations -heap-report) - 6.9.5. 3. gc_node leak detection (automatic)
- 6.9.6. 4. Smart-pointer tracking (
--track-smart-ptr <hexId>) - 6.9.7. 5. JobStatus / Channel / LockBox tracker
- 6.9.8. 6. HandleRegistry (dasHV handle objects)
- 6.9.9. See also
- 7. Tutorials
- 7.1. Language Tutorials
- 7.1.1. Hello World
- 7.1.2. Variables and Types
- 7.1.3. Operators
- 7.1.4. Control Flow
- 7.1.5. Functions
- 7.1.6. Arrays
- 7.1.7. Strings
- 7.1.8. Structs
- 7.1.9. Enumerations and Bitfields
- 7.1.10. Tables
- 7.1.11. Tuples and Variants
- 7.1.12. Function Pointers
- 7.1.13. Blocks
- 7.1.14. Lambdas and Closures
- 7.1.15. Iterators and Generators
- 7.1.16. Modules and Program Structure
- 7.1.17. Move, Copy, and Clone
- 7.1.18. Classes and Inheritance
- 7.1.19. Generic Programming
- 7.1.20. Lifetime and Cleanup
- 7.1.21. Error Handling
- 7.1.22. Unsafe and Pointers
- 7.1.23. String Builder and Formatting
- 7.1.24. Pattern Matching
- 7.1.25. Annotations and Options
- 7.1.26. Contracts
- 7.1.27. Testing with dastest
- 7.1.28. LINQ — Language-Integrated Query
- 7.1.29. Functional Programming
- 7.1.30. JSON
- 7.1.31. Regular Expressions
- 7.1.32. Operator Overloading
- 7.1.33. Algorithm
- 7.1.34. Entity Component System (DECS)
- 7.1.35. Job Queue (jobque)
- 7.1.36. Pointers
- 7.1.37. Utility Patterns (defer + static_let)
- 7.1.38. Random Numbers
- 7.1.39. Dynamic Type Checking
- 7.1.40. Coroutines
- 7.1.41. Serialization (archive)
- 7.1.42. Testing Tools (faker + fuzzer)
- 7.1.43. Interfaces
- 7.1.44. Compiling and Running Programs at Runtime
- 7.1.45. Debug Agents
- 7.1.46. Cross-Context Services with apply_in_context
- 7.1.47. Data Walking with DapiDataWalker
- 7.1.48. Compile-Time Field Iteration with apply
- 7.1.49. Async / Await
- 7.1.50. Structure-of-Arrays (SOA)
- 7.1.51. Delegates
- 7.1.52. Option<T> and Result<T, E>
- 7.1.53. Command-Line Argument Parsing (clargs)
- 7.1.54. Glob Pattern Matching
- 7.2. Building from the Installed SDK
- 7.3. C Integration Tutorials
- 7.3.1. C Integration: Hello World
- 7.3.2. C Integration: Calling daslang Functions
- 7.3.3. C Integration: Binding C Types
- 7.3.4. C Integration: Callbacks and Closures
- 7.3.5. C Integration: Unaligned ABI & Advanced
- 7.3.6. C Integration: Sandbox
- 7.3.7. C Integration: Context Variables
- 7.3.8. C Integration: Serialization
- 7.3.9. C Integration: AOT
- 7.3.10. C Integration: Threading
- 7.3.11. C Integration: Type Introspection
- 7.3.12. C Integration: Mock ECS
- 7.3.13. C Integration: Shared Modules
- 7.3.14. C Integration: Passing Arrays
- 7.4. C++ Integration Tutorials
- 7.4.1. C++ Integration: Hello World
- 7.4.2. C++ Integration: Calling Functions
- 7.4.3. C++ Integration: Binding Functions
- 7.4.4. C++ Integration: Binding Types
- 7.4.5. C++ Integration: Binding Enumerations
- 7.4.6. C++ Integration: Low-Level Interop
- 7.4.7. C++ Integration: Callbacks
- 7.4.8. C++ Integration: Binding Methods
- 7.4.9. C++ Integration: Operators and Properties
- 7.4.10. C++ Integration: Custom Modules
- 7.4.11. C++ Integration: Context Variables
- 7.4.12. C++ Integration: Smart Pointers
- 7.4.13. C++ Integration: AOT Compilation
- 7.4.14. C++ Integration: Serialization
- 7.4.15. C++ Integration: Custom Annotations
- 7.4.16. C++ Integration: Sandbox
- 7.4.17. C++ Integration: Coroutines
- 7.4.18. C++ Integration: Dynamic Scripts
- 7.4.19. C++ Integration: Class Adapters
- 7.4.20. C++ Integration: Standalone Contexts
- 7.4.21. C++ Integration: Threading
- 7.4.22. C++ Integration: Namespace Integration
- 7.4.23. C++ Integration: Binding
shared_ptrviaHandle<T>
- 7.5. Macro Tutorials
- 7.5.1. Macro Tutorial 1: Call Macros
- 7.5.2. Macro Tutorial 2: When Expression
- 7.5.3. Macro Tutorial 3: Function Macros
- 7.5.4. Macro Tutorial 4: Advanced Function Macros
- 7.5.5. Macro Tutorial 5: Tag Function Macros
- 7.5.6. Macro Tutorial 6: Structure Macros
- 7.5.7. Macro Tutorial 7: Block Macros
- 7.5.8. Macro Tutorial 8: Variant Macros
- 7.5.9. Macro Tutorial 9: For-Loop Macros
- 7.5.10. Macro Tutorial 10: Capture Macros
- 7.5.11. Macro Tutorial 11: Reader Macros
- 7.5.12. Macro Tutorial 12: Typeinfo Macros
- 7.5.13. Macro Tutorial 13: Enumeration Macros
- 7.5.14. Macro Tutorial 14: Pass Macro
- 7.5.15. Macro Tutorial 15: Type Macro
- 7.5.16. Macro Tutorial 16: Template Type Macro
- 7.5.17. Macro Tutorial 17: Quasi-quotation Reference
- 7.6. dasHV (HTTP / WebSocket) Tutorials
- 7.7. dasPUGIXML (XML) Tutorials
- 7.8. dasStbImage (Image I/O) Tutorials
- 7.9. dasSQLITE (SQL) Tutorials
- 7.9.1. SQL-01 — Hello dasSQLITE
- 7.9.2. SQL-02 — Declare a Table, Insert
- 7.9.3. SQL-03 — Auto-Increment Primary Key
- 7.9.4. SQL-04 — Reading Rows with
_sql - 7.9.5. SQL-05 — Parameter Binding
- 7.9.6. SQL-06 — Error Handling
- 7.9.7. SQL-07 — Anatomy of
_sql - 7.9.8. SQL-08 —
_wherePredicates: the Full Surface - 7.9.9. SQL-09 —
_selectProjections - 7.9.10. SQL-10 —
_order_byand_order_by_descending - 7.9.11. SQL-11 —
takeandskip: Paging - 7.9.12. SQL-12 —
distinct - 7.9.13. SQL-12b — Set operations
- 7.9.14. SQL-13 — Aggregates:
sum/avg/… - 7.9.15. SQL-14 —
_group_byand_having - 7.9.16. SQL-15 —
_join(inner equi-join) - 7.9.17. SQL-16 — All Join Shapes
- 7.9.18. SQL-17 — Subqueries
- 7.9.19. SQL-18 — NULL Handling:
Option<T>Everywhere - 7.9.20. SQL-19 — UPDATE
- 7.9.21. SQL-20 — DELETE
- 7.9.22. SQL-21 — UPSERT
- 7.9.23. SQL-22 — Transactions
- 7.9.24. SQL-23 — Foreign keys
- 7.9.25. SQL-24 — Indexes
- 7.9.26. SQL-25 — Defaults + computed columns
- 7.9.27. SQL-26 — Custom type adapters
- 7.9.28. SQL-27 — BLOB round-trip
- 7.9.29. SQL-28 — JSON and BLOB columns
- 7.9.30. SQL-29 — Column metadata
- 7.9.31. SQL-30 — Listing tables
- 7.9.32. SQL-31 — Views
- 7.9.33. SQL-32 — User-defined SQL scalar functions
- 7.9.34. SQL-33 — PRAGMA tuning
- 7.9.35. SQL-34 — Backup, VACUUM, integrity check
- 7.9.36. SQL-35 — Streaming results with
_each_sql - 7.9.37. SQL-36 —
ATTACH DATABASE: cross-DB queries - 7.9.38. SQL-37 — Bulk operations: making writes fast
- 7.9.39. SQL-38 — Concurrency: threads, contention
- 7.9.40. SQL-39 —
schema_from: struct mirrors the DB - 7.9.41. SQL-40 — FTS5 full-text search
- 7.9.42. SQL-41 — Triggers: DB-level callbacks
- 7.9.43. SQL-42 — multi-version ETL with schema_from
- 7.9.44. SQL-43 — versioned schema migrations
- 7.10. dasAudio (Audio) Tutorials
- 7.11. daStrudel (Live-Coding) Tutorials
- 7.11.1. STRUDEL-01 — Hello Pattern
- 7.11.2. STRUDEL-02 — Mini-Notation Fundamentals
- 7.11.3. STRUDEL-03 — Mini-Notation Advanced
- 7.11.4. STRUDEL-04 — Time Manipulation
- 7.11.5. STRUDEL-05 — Euclidean Rhythms
- 7.11.6. STRUDEL-06 — Stacking & Combining
- 7.11.7. STRUDEL-07 — Per-Voice FX & Combinators
- 7.11.8. STRUDEL-08 — Effects & Filters
- 7.11.9. STRUDEL-09 — ADSR & Envelope Shaping
- 7.11.10. STRUDEL-10 — Scales & Music Theory
- 7.11.11. STRUDEL-11 — Synthesis
- 7.11.12. STRUDEL-12 — Samples
- 7.11.13. STRUDEL-13 — SF2 SoundFont Playback
- 7.11.14. STRUDEL-14 — MIDI Files
- 7.11.15. STRUDEL-15 — Live-Reloading Patterns
- 7.11.16. STRUDEL-16 — HRTF: 3D Positional Override for Pan
- 7.12. dasPEG (Parser Generator) Tutorials
- 7.1. Language Tutorials
- 8. daslang strudel vs strudel.cc — Feature Comparison