5. Tutorials
This section provides hands-on tutorials organized into four groups:
Language Tutorials — learn daslang syntax and standard library features
C Integration Tutorials — embed daslang in a C host using the
daScriptC.hAPIC++ Integration Tutorials — embed daslang in a C++ host using the native
daScript.hAPIMacro Tutorials — write compile-time code transformations using the daslang macro system
5.1. Language Tutorials
These tutorials introduce daslang’s core features step by step.
Each comes with a companion .das file in tutorials/language/ that you
can run directly:
daslang.exe tutorials/language/01_hello_world.das
The tutorials are designed to be followed in order. Each one builds on concepts introduced in earlier 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
These tutorials show how to embed daslang in a C application using the
daScriptC.h API. Each tutorial comes with a .c source file and a
companion .das script in tutorials/integration/c/.
- 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
These tutorials show how to embed daslang in a C++ application using the
native daScript.h API. Each tutorial comes with a .cpp source file
and a companion .das script in tutorials/integration/cpp/.
- 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
These tutorials teach daslang’s compile-time macro system: call macros,
reader macros, function macros, and AST manipulation. Each tutorial has
two source files — a module (.das) that defines the macros and a
usage file that exercises them — because macros cannot be used in the same
module that defines them.
Run any tutorial from the project root:
daslang.exe tutorials/macros/01_call_macro.das
- 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