clay icon indicating copy to clipboard operation
clay copied to clipboard

[Question] What are clay's naming convention?

Open soypat opened this issue 9 months ago • 3 comments

I've noticed there are at least 3 rules to naming identifiers. I understand in C we prefix the identifier with the module name to avoid naming conflicts with other libraries since namespace is global.

  • Typical C module namespacing rule: Clay_ElementDeclaration
  • Double-underscore rule: Clay__Warning
  • Mixed rule: Clay__Clay_ElementDeclarationWrapper

What are the rules for using these styles?

soypat avatar Mar 05 '25 12:03 soypat

The first one is for the public API, the second is for internals and the third is because those are names generated by a macro. In that case we need them to be private, so we have to add Clay__ in front of the name, but that adds on to the existing Clay_. See below for a bit more info on that. https://github.com/nicbarker/clay/blob/5009146c65e47da332d5f6ddaa29091d07b9fb7c/clay.h#L138-L145

FintasticMan avatar Mar 05 '25 12:03 FintasticMan

Thank you for your answer. If we did not miss any identifier naming rules I guess we can close this. (I guess the one remaining is CLAY_ for macros...)

soypat avatar Mar 05 '25 13:03 soypat

There's a bit of info in the README here as well 🙂 https://github.com/nicbarker/clay?tab=readme-ov-file#naming-conventions

Naming Conventions

  • "CAPITAL_LETTERS()" are used for macros.
  • "Clay__" ("Clay" followed by double underscore) is used for internal functions that are not intended for use and are subject to change.
  • "Clay_" ("Clay" followed by single underscore) is used for external functions that can be called by the user.

nicbarker avatar Mar 05 '25 21:03 nicbarker