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

Support SingularNameFor in (quantity) unit slots #373

Closed
chiphogg opened this issue Jan 14, 2025 · 3 comments · Fixed by #374
Closed

Support SingularNameFor in (quantity) unit slots #373

chiphogg opened this issue Jan 14, 2025 · 3 comments · Fixed by #374
Labels
⬇️ affects: code (interfaces) Affects the way end users will interact with the library 📁 kind: bug Something isn't working correctly, or there's a mistake 💪 effort: tiny A trivial change
Milestone

Comments

@chiphogg
Copy link
Contributor

This doesn't work, but it should (https://godbolt.org/z/bY3r1bKzc):

constexpr auto ONE_REV = make_constant(revolution);
QuantityD<Radians> two_pi_rad = ONE_REV;
@chiphogg chiphogg added 📁 kind: bug Something isn't working correctly, or there's a mistake 💪 effort: tiny A trivial change ⬇️ affects: code (interfaces) Affects the way end users will interact with the library labels Jan 14, 2025
@chiphogg chiphogg added this to the On deck milestone Jan 14, 2025
chiphogg added a commit that referenced this issue Jan 15, 2025
I thought it through, and realized this is pretty clearly for "quantity"
type slots only, not "point" type slots.  The reason this exists is to
participate in multiplications, divisions, and powers with quantity
makers.  Quantity points don't have multiplicative semantics.

Fixes #373.
@hoffbrinkle
Copy link
Contributor

Oh, I stumbled across this a while ago and didn't realize it was a bug. Excited to see it fixed though!

@chiphogg
Copy link
Contributor Author

I think the omission was originally intentional, because I wanted people to write .in(meters), not .in(meter). I still do. However, it's just a stylistic consideration. And as the example here shows, sometimes that stylistic consideration cuts in the other direction --- I found make_constant(revolution) easier to read than make_constant(revolutions), in terms of English grammar.

So now I think it's fine to enable this mapping, and just trust people's intrinsic incentives to write code that reads well. (This is in the same spirit as the earlier change to let people multiply and divide quantity makers. meters / seconds works now, although when Au was open sourced, meters / second was the only option.)

@chiphogg chiphogg reopened this Jan 15, 2025
@chiphogg
Copy link
Contributor Author

Did not mean to reopen. 😛

@chiphogg chiphogg modified the milestones: On deck, 0.4.2 Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⬇️ affects: code (interfaces) Affects the way end users will interact with the library 📁 kind: bug Something isn't working correctly, or there's a mistake 💪 effort: tiny A trivial change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants