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:
force_inline
instead of redefining inline
)borrowed_item
vs owned_item
)Entry
for non-collection elements)ts_language_
consistently)0x25A1
instead of decimal 9633
for 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) {
// ...
}
}
Enter the URL of a public GitHub repository