Prompt
Choose identifiers that accurately represent their purpose, semantics, and relationship to the codebase. Names should be self-documenting and consistent with established patterns in the module or API.
Key principles:
- Avoid redefining language keywords with preprocessor macros (use descriptive alternatives like
force_inlineinstead of redefininginline) - Parameter names should reflect ownership semantics (
borrowed_itemvsowned_item) - Type names should accurately describe their purpose (avoid misleading suffixes like
Entryfor non-collection elements) - Maintain consistent naming patterns within APIs (use established prefixes like
ts_language_consistently) - Use self-explanatory representations (hexadecimal
0x25A1instead of decimal9633for Unicode values)
Example of good naming:
// Good: Clear ownership semantics
static inline void analysis_state_set__push_by_clone(
AnalysisStateSet *self,
AnalysisState *borrowed_item // Clearly indicates caller retains ownership
) {
// ...
}
// Good: Consistent API prefix and self-documenting hex value
int ts_language_symbol_type_is_named(const TSLanguage *self, TSSymbol typeId) {
// Use 0x25A1 instead of 9633 for Unicode box character □
while (iswspace(lexer->lookahead) || 0x25A1 == lexer->lookahead) {
// ...
}
}