Idea (borrowed from Coda)
A $ operator that guarantees compile-time evaluation of an expression or statement — not a hint. $expr embeds the computed value into the binary; ${ ... } runs the statement during compilation. If the compiler cannot evaluate it at compile time, the program is ill-formed and compilation fails (rather than silently falling back to runtime).
Coda examples:
string path = $strcat(#file(), "/config.json"); // folded at compile time
${
generate_lookup_table(); // runs during compilation
}
Why Aether might want it
Aether already has compile-time when (platform branching) and const arrays (#, the mquickjs atoms table). The gap $ fills is the guarantee: "this table/constant MUST be computed at build time, and if it can't be, tell me — don't quietly emit runtime code." The natural use case is generated lookup tables (e.g. the mquickjs atoms table, CRC/hash tables, S-boxes) where you want the compiler to fold the generator and fail loudly if some input isn't const-foldable.
The distinction from a hint matters: a hint that silently degrades to runtime evaluation is the "green build that proves nothing" failure mode for anything that's supposed to be a compile-time constant.
Priority
Low. Aether's const arrays + compile-time when already cover most of the practical need; this is the incremental "make it a guarantee, with an error on failure" refinement, not a new capability. Filing so the language line can weigh it — related prior art: #482 (compile-time constant evaluation, Nim-inspired), #483 (when/static-if), #879 (sizeof/offsetof in const initializers).
Provenance
From a survey of github.com/…/coda's spec (§6.10 Compile-Time Evaluation, §2.8). Coda is a separate from-scratch systems language; this is an idea-borrow.
Idea (borrowed from Coda)
A
$operator that guarantees compile-time evaluation of an expression or statement — not a hint.$exprembeds the computed value into the binary;${ ... }runs the statement during compilation. If the compiler cannot evaluate it at compile time, the program is ill-formed and compilation fails (rather than silently falling back to runtime).Coda examples:
Why Aether might want it
Aether already has compile-time
when(platform branching) and const arrays (#, the mquickjs atoms table). The gap$fills is the guarantee: "this table/constant MUST be computed at build time, and if it can't be, tell me — don't quietly emit runtime code." The natural use case is generated lookup tables (e.g. the mquickjs atoms table, CRC/hash tables, S-boxes) where you want the compiler to fold the generator and fail loudly if some input isn't const-foldable.The distinction from a hint matters: a hint that silently degrades to runtime evaluation is the "green build that proves nothing" failure mode for anything that's supposed to be a compile-time constant.
Priority
Low. Aether's const arrays + compile-time
whenalready cover most of the practical need; this is the incremental "make it a guarantee, with an error on failure" refinement, not a new capability. Filing so the language line can weigh it — related prior art: #482 (compile-time constant evaluation, Nim-inspired), #483 (when/static-if), #879 (sizeof/offsetof in const initializers).Provenance
From a survey of
github.com/…/coda's spec (§6.10 Compile-Time Evaluation, §2.8). Coda is a separate from-scratch systems language; this is an idea-borrow.