Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add machinery for built-in constants, such as c #335

Merged
merged 2 commits into from
Dec 2, 2024

Conversation

chiphogg
Copy link
Contributor

@chiphogg chiphogg commented Dec 2, 2024

For Au's built-in constants, we follow the exact same policies as for
units, including:

  • A new include folder, "au/constants/..."
  • A new target, "//au:constants", which globs headers from that folder
  • Corresponding unit tests
  • Inclusion in the single-file script by individual names
  • An --all-constants option for the single-file script

Oh, and while I was updating the single-file script, I noticed a slight
"bug": ever since we started providing _fwd.hh files for the units,
the single file script was treating those files as their own units.
This doesn't hurt anything, but it's just a little silly (see image).
This PR fixes that bug as well.

image

We don't provide _fwd.hh files for constants, because there's
nothing we could really forward declare.

Constant objects are defined with spelled-out names in ALL_CAPS
format. The corresponding file is the snake-case version. This keeps
the constant itself unambiguous. We expect end users to actually use
them in the following manner:

constexpr auto c = au::SPEED_OF_LIGHT;

Finally, we now mention new constants in the release notes.

Helps #90. Remaining work includes adding more constants, and adding
documentation.

For Au's built-in constants, we follow the exact same policies as for
units, including:

- A new include folder, `"au/constants/..."`
- A new target, `"//au:constants"`, which globs headers from that folder
- Corresponding unit tests
- Inclusion in the single-file script by individual names
- An `--all-constants` option for the single-file script

We _don't_ provide `_fwd.hh` files, because there's nothing we could
really forward declare.

Constant objects are defined with spelled-out names in `ALL_CAPS`
format.  The corresponding file is the snake-case version.  This keeps
the constant itself unambiguous.  We expect end users to actually use
them in the following manner:

```cpp
constexpr auto c = au::SPEED_OF_LIGHT;
```

Finally, we now mention new constants in the release notes.

Helps #90.  Remaining work includes adding more constants, and adding
documentation.
@chiphogg chiphogg added release notes: ✨ lib (enhancement) PR enhancing the library code release notes: 📏 lib (new units/constants) PR adding new units or constants to the library labels Dec 2, 2024
@chiphogg chiphogg merged commit 9b2f9a7 into main Dec 2, 2024
13 checks passed
@chiphogg chiphogg deleted the chiphogg/first-constants#90 branch December 2, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: ✨ lib (enhancement) PR enhancing the library code release notes: 📏 lib (new units/constants) PR adding new units or constants to the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants