Version: 1.1.0
Feature toggles
Feature toggles are compile-time switches. They keep unfinished or hardware-specific code out of a build without commenting it out.
Essentials
- A toggle is read with
comptime if. - Dead branches are erased, so they do not have to type-check for the disabled target.
- Name toggles after the capability, not after the person who added them.
- Defaults should match the stable product.
Example
comptime if env_get_bool["FAST_MATH", False]():
print("fast")
else:
print("strict")
Keep in mind
Do not use a toggle to paper over a type error. Fix the error or constrain the declaration.