7. 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
7.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.
- 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.2. Building from the Installed SDK
Once daslang is installed, you can build the integration tutorials — or your
own projects — against the SDK using CMake’s find_package(DAS).
7.3. 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/.
The installed SDK ships with a standalone CMakeLists.txt that lets you
build all C tutorials directly against the SDK — see
tutorial_building_from_sdk.
- 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.4. 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/.
The installed SDK ships with a standalone CMakeLists.txt that lets you
build all C++ tutorials directly against the SDK — see
tutorial_building_from_sdk.
- 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.5. 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
- 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
These tutorials cover the dashv module — HTTP client and server
bindings built on libhv. The
companion .das files are in tutorials/dasHV/.
Run any tutorial from the project root:
daslang.exe tutorials/dasHV/01_http_requests.das
7.7. dasPUGIXML (XML) Tutorials
These tutorials cover the dasPUGIXML module — XML parsing, building,
XPath queries, and automatic struct serialization using
pugixml. The companion .das files are in
tutorials/dasPUGIXML/.
Run any tutorial from the project root:
daslang.exe tutorials/dasPUGIXML/01_parsing_and_navigation.das
7.8. dasStbImage (Image I/O) Tutorials
These tutorials cover the stbimage_boost module — image loading,
saving, format conversion, and pixel manipulation using
stb_image. The companion
.das files are in tutorials/dasStbImage/.
Run any tutorial from the project root:
daslang.exe tutorials/dasStbImage/01_loading_images.das
7.9. dasAudio (Audio) Tutorials
These tutorials cover the audio_boost module — audio playback,
3D spatial audio, effects, WAV I/O, and MIDI. The companion
.das files are in tutorials/dasAudio/.
Run any tutorial from the project root:
daslang.exe tutorials/dasAudio/01_hello_sound.das