Build inputs let you declare named values that resolve before the compiler processes your source modules. They feed settings like version strings and feature flags into ordinary compile-time constants.
Accepted deferred syntax. Build inputs are queued implementation work. The examples below show the accepted end-state contract, not current compiler support. See Progress for implementation status.
A simple build input
project #= |
name = "my_project",
version #Import of String = "0.1.0",
entry_root = "src",
|
The #Import of String part tells the build system that version can be overridden from the command line. When no override arrives, the default "0.1.0" applies.
Source-level build inputs
Any source module can declare its own build input the same way:
api_url #Import of String = "https://api.example.com"
The build system validates every contract before module compilation. Same-name contracts must agree on type and default value.
Accepted types
Build inputs accept String, Int, Float, Bool, Char and optional forms of those types. Defaults must be plain literal values, not expressions or templates.
Related concepts
Accepted deferred design. This page defines the final source contract. The current compiler does not yet implement this surface. See Progress for current status.
Build inputs let config and source declare named primitive values that resolve before module AST compilation. They feed project identity, feature flags and environment-specific settings into ordinary compile-time constants.
Direct project #Import fields
A direct primitive or optional field of project may declare a build-input contract using #Import of T. Nested project fields cannot declare imports.
Accepted imported-value types are String, Int, Float, Bool, Char and optional forms of those types.
project #= |
name = "moth_docs",
version #Import of String = "0.1.0",
channel #Import of String? = none,
entry_root = "src",
|
#Import is constant-source syntax. It isn't a source import or a wrapper type.
A direct project #Import value resolves in this order:
- explicit CLI or programmatic build input
- builder-provided primitive global
- the folded declaration default
- a structured missing-input diagnostic
Resolution happens during config compilation before Stage 0 applies fields such as entry_root.
A fixed direct project field is not an import contract. When a same-name source #Import uses the same primitive type and optionality, the fixed field is its authoritative provider and blocks CLI override. Same-name source declarations must still agree on required or default state and the normalised default value.
Source #Import contracts
Source #Import is intentionally narrow so every project-wide contract can be validated before module AST compilation.
A source declaration may use only the accepted primitive or optional types listed for project fields.
A source default must be self-contained. The only accepted forms are:
- a
String literal - a signed
Int literal - a signed
Float literal - a
Bool literal - a
Char literal none for an optional contract- a matching primitive literal for an optional contract
Source defaults cannot contain a name, template, operator expression, call, cast, field projection, collection, record or another imported value. Stage 0 doesn't run a second general constant evaluator before AST.
api_url #Import of String = "https://api.example.com"
max_retries #Import of Int = 3
debug_mode #Import of Bool = false
Project-wide resolution order
Same-name contracts must agree on primitive type, optionality, required or default state and the normalised default value. Different defaults are conflicting contracts.
The project-wide resolution order is:
- a compatible fixed direct project field, which is authoritative and cannot be overridden
- a resolved direct project
#Import field - explicit CLI or programmatic input for a source-only contract
- a builder-provided primitive global
- the shared source default
- a missing-input diagnostic
Unknown explicit inputs are diagnosed only after every selected source contract is known.
The resolved value enters module AST as an ordinary folded constant. It creates no runtime wrapper or HIR category.
Related concepts