| name | cpp-style |
| description | kotatsu C++ coding conventions — redundancy elimination (the rule we care most about), file organization, macro.h isolation, dual-mode exception policy, template deduction and type-trait rules, naming, modern C++ preferences. Read BEFORE writing or modifying any C++ code. |
kotatsu C++ Coding Style
Redundancy Is a Defect
This is the convention we care most about. Redundant code is not a style
nit — it actively misleads: every guard implies the guarded state can
occur, every branch implies it can be taken, every parameter implies a
caller needs it. When that implication is false, the reader wastes time
defending against ghosts.
- Every branch must be reachable. Before adding a guard or fallback,
prove the state can actually occur — construct the input that hits it.
If you can't, don't write it.
- No speculative generality. No parameters, options, hooks, or
abstraction layers for hypothetical future callers. Add them when the
second real caller arrives.
- One way to do each thing. Don't leave an old path alive next to its
replacement "just in case" — migrate all callers and delete it in the
same change.
- Re-read after every change. Edits leave residue: conditions that
became constant, variables read once, branches that now collapse,
else after return, a helper with one remaining caller. Fold them
before you're done — simplification that removes a concept beats one
that merely shortens lines.
- Delete, don't comment out. Git history is the archive.
Files & Organization
- Headers are
.h with #pragma once — never include guards. Public
headers live under include/kota/<module>/.
- Source extensions are mixed across modules (
.cpp in some, .cc in
others) — match the module you are editing.