Inferred division from defined multiplication relations#1354
Inferred division from defined multiplication relations#1354angularsen merged 5 commits intoangularsen:release/v6from
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. |
angularsen
left a comment
There was a problem hiding this comment.
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 <[email protected]>
1950b51 to
6a5ad04
Compare
angularsen
left a comment
There was a problem hiding this comment.
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