-
Notifications
You must be signed in to change notification settings - Fork 88
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
Bikeshedding force_in(Unit)
#534
Comments
The above naming is also more consistent with the |
I could see this becoming idiomatic. One downside may be that we're changing the verb, from "in" to "to". The reason to prefer keeping the verb the same is that the API names become easier to compose, easier to "guess". That said, I think |
Yes, I agree that naming is hard ;-) The first question is, do we agree that The second one is if we have any better candidates. |
I think |
That makes sense. |
Please note that at some point, we may also have |
I thought about |
As I (not native speaker) understand it, Are 'stored_in', 'kept_in' or 'hold_in' alternatives? |
"Stored", "kept", or "hold" are not a valid solution here. We need two options for conversion. One that means 'convert safely' (e.g., no data truncation), and for that, we have |
Ah ok, thanks for clarification. So, 'unsafe_cast_to' is a little bit too unhandy? |
As we discussed before, the spelling of
distance.force_in(si::metre)
may be confusing. Also, the C++ standard does not use "force" word anywhere to force a conversion.AU library is using
coerse_in(Unit)
for that reason but I personally do not think it helps here.I just thought about renaming it to
cast_to(si::metre)
. Lets see some examples:quantity q1 = 42 * m; quantity q2 = q1.in(mm); quantity q3 = q1.cast_to(km); quantity q4 = q1.numerical_value_in(mm); quantity q5 = q1.cast_numerical_value_to(km); quantity q6 = q1.numerical_value_cast_to(km);
What do you think of the above? Which one looks better to you,
q5
orq6
?The text was updated successfully, but these errors were encountered: