-
Notifications
You must be signed in to change notification settings - Fork 91
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
Renaming of accessor functions #484
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are my thoughts.
-
Requiring an interface like
q.value_in(m)
solves a real engineering (programming integrated over time) issue. -
Library implementation and tests are unfortunately verbose,
having gone fromq.number()
toq.value_ref_in(q.unit)
. -
I'm thinking we should only have
value_ref_in
(and not alsovalue_in
).
We explicitly need to usevalue_ref_in
rather thanvalue_in
to not incur a copy after avalue_cast
or when we knowq
is in the correct type.
Unfortunately, most of the time (all the time, for all I could see in this PR)
we don't actually need the result to be a reference to the underlying number.I can see someone getting an error because they used the wrong reference, which is a good thing.
I can also see them dropping the_ref
because usingvalue_in
will result in correct code anyways, albeit less efficient.
Consider another possible point against having both An unwary user would not only use |
Of course, I don't mean magically correct. |
We can change this behavior to return-by-value for rvalue-qualified overloads. However, in such a case |
@JohelEGP, thanks for the feedback! What do you think about the I am also interested to hear what others think of those changes. Should we proceed, refactor, or maybe abandon them? |
Of course, the same applies to the other interfaces that do the same as the ( |
bbaf1b5
to
88a6a3a
Compare
19f7ae8
to
2b2f62d
Compare
…the implemenation and constraints
It was lots of work but I think we are done now. Do you have any feedback before I merge it? |
I think the summary is out of date. It'd be good to update it so that it summarizes the API changes that are landing. Also, it looks like we're still using the "force" word, even though we think it's confusing. Did you end up deciding it was the least-bad option? |
I've updated the summary.
I do not have a better alternative as I do not like |
Changes introduced by this PR:
quantity::numerical_value()
refactored toquantity::numerical_value_ref_in(Unit)
quantity_point::quantity_from_origin
refactored toquantity_point::quantity_ref_from(PointOrigin)
quantity
andquantity_point
compound assignment, pre-increment, and pre-decrement operators now preserve value categoryquantity::numerical_value_ref_in(Unit)
allowed only for lvaluesquantity_point::quantity_ref_from(PointOrigin)
allows only for lvaluesquantity_point::quantity_from(PointOrigin)
addedquantity::force_numerical_value_in(Unit)
addedquantity::force_in(Unit)
andquantity_point::force_in(Unit)
addedResolves #477 and relates to #479