baml_language/sdks/cpp/STYLE.md
Layout is Google; naming is the C++ standard library's.
BasedOnStyle: Google (see
.clang-format). Headers use .h, sources use .cc, include guards
use the BAML_..._H_ form.underscore_style, consistent with the ISO standard library) --
the same convention Boost uses. Enforced by clang-tidy
readability-identifier-naming (see .clang-tidy).| Entity | Case | Examples |
|---|---|---|
| types | snake_case | baml::variant, baml::future, baml::lit, baml::error, baml::thrown<U>, detail::call_state |
| functions and methods | snake_case | baml::match, future::cancel, codec<T>::encode, detail::call_sync |
| constants | snake_case | baml::unset (type baml::unset_t, the nullopt/nullopt_t pattern) |
| enumerators | snake_case | lit_shape::integer (int/bool/enum are keywords; spell them out) |
| template parameters | CamelCase | T, Ret, ThrownU, WriteValue |
| macros | BAML_UPPER | BAML_LIT, BAML_TEST |
| private members | trailing _ | state_, engine_call_id_ |
baml::variant is the one vocabulary drift from BAML's own terminology:
lowercase union is a C++ keyword, and variant is the std name for the
same shape.
extern "C" symbols and everything in the C ABI header
(baml_cffi.h: BamlApiV1, BamlBuffer, ...) keep their contract
spellings.pb/) keeps protoc's conventions.SleepMs stays
SleepMs). Suffixes the generator adds are snake and follow the other
bridges: the async sibling of SleepMs is SleepMs_async (python
parity), the opts struct for probe is probe_opts, setters are
set_<param>.baml::error contract is the
bridge's error surface. This is a knowing deviation from the Google
guide's no-exceptions rule.