Skip to main content

declare_knob

Macro declare_knob 

Source
macro_rules! declare_knob {
    (scopable $ident:ident, $ty:ty, $default:expr, $doc:literal) => { ... };
    ($ident:ident, $ty:ty, $default:expr, $doc:literal) => { ... };
    (@ $ident:ident, $ty:ty, $default:expr, $doc:literal, $scopable:literal) => { ... };
}
Expand description

Declare a knob: a typed runtime setting resolved from override / environment / default, registered for listing.

The static is named exactly like the environment variable (the TRACT_ prefix included), so one grep finds both the declaration and any use, and the env-var name is derived from the identifier — there is no separate string to drift.

Prefix the name with scopable for a knob read only while a model is transformed or prepared, never at eval nor cached for the process: such a knob honours a KnobScope.

ⓘ
declare_knob!(TRACT_MY_FLAG, bool, false, "Enable the thing.");
declare_knob!(scopable TRACT_MY_RULE_OFF, bool, false, "Skip my rewrite rule.");
// ... later ...
if TRACT_MY_FLAG.get() { /* ... */ }