-
Notifications
You must be signed in to change notification settings - Fork 391
Inferred division from defined multiplication relations #1354
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
Conversation
b7456ea
to
a256eab
Compare
I rebased this on the latest changes in #1329 which makes it much cleaner. Example of an interesting situation that occurs here, we previously defined:
If we infer division from multiplication, one of those has to add or lose a kilo 😅 |
a256eab
to
df96c8e
Compare
Will review this next, hopefully in the next few days.
Haha 😆 But it will still work, right? |
Yes, it will work, except we're not sure why the original contributor chose a particular unit for an operator and if it matters, with precision for example. Also, this PR is more of an experiment than a serious proposal. There's some questions about the "magic" of it, and I took some liberties with implicit/explicit conversion between |
Although the Density and Mass Concentration share the same units, they are not interchangeable- they describe different types of ratios. Casting between them (either implicitly or explicitly) makes no sense.. |
df96c8e
to
0491bfb
Compare
Thanks for the explanation! That makes the concept of inferred division a bit harder, given that we currently have:
which leads to these inferred ambiguous operators, which is what I tried to solve with my casting shenanigans:
The latter is currently not defined, so skipping it would not be a breaking change. I've reworked this PR to do that and removed the casting stuff. |
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.
I like where this is going and would like to get it merged.
Some comments so far.
44bd139
to
1950b51
Compare
### Changes - Change `Duration` from explicit to implicit cast to/from `TimeSpan` - Remove operator overloads for `TimeSpan` now covered by implicit cast for all but left operands ### Background See #1354 (comment) One issue is that the operator overloads only work when `TimeSpan` is the right operand. I changed the code generation to take this into account, but another option would be to make a breaking change where we just don't support `TimeSpan` as the left operand at all. Then users would have to cast explicitly, or for multiplication just reverse the operands. This would affect 13 operators: ``` TimeSpan * Acceleration TimeSpan * ElectricCurrent TimeSpan * ElectricCurrentGradient TimeSpan * ForceChangeRate TimeSpan * KinematicViscosity TimeSpan * MassFlow TimeSpan * MolarFlow TimeSpan * Power TimeSpan * PressureChangeRate TimeSpan * RotationalSpeed TimeSpan * Speed TimeSpan * TemperatureChangeRate TimeSpan * VolumeFlow ``` Of which only 6 are used in tests so I assume are supported in v5: ``` TimeSpan * KinematicViscosity TimeSpan * MassFlow TimeSpan * Power TimeSpan * RotationalSpeed TimeSpan * TemperatureChangeRate TimeSpan * Speed ``` --------- Co-authored-by: Andreas Gullberg Larsen <andreas.larsen84@gmail.com>
1950b51
to
6a5ad04
Compare
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.
Looks good to me, just one minor comment we can address later.
Division now inferred by f7ce00b - Inferred division from defined multiplication relations (angularsen#1354)
Nuget on the way |
In #1329 this proposal came up:
This PR is an experiment implementing this.
Breaking changes:
TimeSpan = Volume / VolumeFlow
=>Duration = Volume / VolumeFlow