Skip to Content

Advanced

This part covers the advanced side of the language: @Test tests and assertions, the virtual clock, generators, runtime reflection, and more.

Tests and Assertions@Test on a public parameterless function makes it a test function; mush test runs each one and prints a summary. The assertion family lives in the std::Test module, and failures flow through fail.
Virtual ClockClock is a host-injected extern module providing the virtual clock read surface: scripts get time that is deterministic and testable.
Generatorgenerator is a toolchain-facing metaprogramming declaration: a generator module is invoked at compile time and injects members into target types according to its rules. It is meant for cases that auto-generate boilerplate; everyday business code never touches it.
ReflectionReflection obtains the following at runtime: what type a value is, what members it has, and what attributes are attached to its members. The entry point is the std::Reflect module's typeof(T) syntax, which produces five non-constructible handle types: Type, Field, Prop, Attr, Method.
PreprocessA # at the start of a line triggers a preprocessing directive: before compilation, source is trimmed by symbol conditions. A good fit for forks like "the same code, with the editor build carrying an extra set of debug functions".
Queryquery is the loop statement for iterating over ECS entities: it filters entities by component type, binds component fields into the loop body as variable views, and reads and writes go straight to host storage. For declaring components see Components.
Componentcomponent declares an ECS component: a plain-old-data (POD) storage unit with fields and no behavior, read and written by a query that filters entities by type.
Usingusing confines a resource's lifetime to a block scope: you hold the resource on entry, and leaving the block automatically calls Dispose. It fits resources that need explicit release — file handles, database connections, transactions.
JsonThe std Json module converts between JSON and language values in both directions: strongly typed Parse / Write, the dynamic ParseAny, and the Stringify serializer.
StdThe standard library is the built-in package named std.
HostMushScript scripts run inside a host environment (the CLI, a game engine, and an editor are each hosts). The host injects capabilities into the script through the extern surface: its three kinds of injections (modules, functions, and global variables) each come with their own rules, and the script side only consumes them, never declares them. Alongside the injection surface comes the opaque handle type, whose values likewise can only come from the host.
Last updated on October 11, 2026