Skip to Content

MushScript Reference

This is a reference manual for MushScript: every page covers one feature unit, organized by topic. It does not teach the language from scratch — if you are starting from zero, begin with the Getting Started part.

MushScript is a statically typed scripting language. Its core traits:

  • Immutable by default: val is the default, var is the exception.
  • null is part of the type: “may be empty” must be written into the type and is strictly enforced at compile time.
  • Built-in vectors and colors: vec2/vec3/vec4/color — seven types in one family, with direct swizzle access.
  • Composition and inheritance coexist: classes derive along a single inheritance chain; cross-cutting capabilities are composed explicitly through protocols, mixins, and extensions.
  • Errors are values: failure is not expressed with exceptions but is part of a function’s signature.

Scope

This manual describes the scripting edition of MushScript, whose syntax is a subset of the native edition. Most of the syntax and semantics described here hold in the native edition too, but features the native edition adds on top are outside this manual’s scope.

Conventions

Keywords and API names stay in English exactly as they are written in code.

Parts

Getting StartedThis part covers the runtime environment and a quick syntax reference.
Basic ValuesThis part covers every basic value in the language: three kinds of binding, the integers and the two decimal families, bool and char, strings and their interpolation, time values, vectors and colors, and explicit type conversions. Each value gets its literal forms, runnable examples, and edge-case behavior.
Operators and Control FlowThis part covers the language's expressions and statements: operators and precedence, conditionals and matching, loops, patterns, and more.
FunctionsThis part covers the full declaration surface of functions: parameter modifiers, default parameters, named arguments, variadic parameters and spread calls, overloads, and generic constraints.
Collections and TextThis part covers the language's container family and text handling: lists, sets, maps, and more.
TypesThis part covers the full landscape of custom types: nullable types, structs, classes, tuples, props, enums, and more.
Organizing CodeThis part covers how code is organized and shared: modules, packages, imports, and visibility.
Events and ReactivityThis part covers the event system and the reactive features: events, subscriptions, event pipelines, and more.
AsyncAsync in MushScript is a single-threaded, interleaved suspend/resume state machine. There are no threads; every interleaving point is marked explicitly by await.
AdvancedThis part covers the advanced side of the language: @Test tests and assertions, the virtual clock, generators, runtime reflection, and more.
Last updated on October 11, 2026