Date: Wed, 19 Jun 2024 09:52:02 +0200
Hi Mateusz,
that is a good overview of the discussion.
The initial example by Tiago was:
```
quantity Volume = 1.0 * m*m*m;
quantity Temperature = (28.0 * deg_C).in(K);
quantity n_ = 0.04401 * kg / mol;
quantity R_boltzman = 8.314 * N * m / (K * mol);
quantity mass = 40.0 * kg;
quantity Pressure = R_boltzman * Temperature * mass / n_ / Volume;
std::cout << Pressure << std::endl;
```
Removing the multiplicative syntax would only help insofar as:
`quantity` now has to be used explicitly; with multiplication `auto` would have been possible instead.
auto Temperature = (28.0 * deg_C).in(K);
Only quantity and never quantity_point is used for the other units. So users have to know that quantity_point exists and that it has to be used specifically for temperature, even it is possibly not used for any of the other units (see this example). That still keeps the temperature error-prone:
auto Temperature = (quantity{28.0, deg_C}).in(K);
is wrong. But looks correct for users not knowing quantity_point.
With the proposed change, we would always have to write:
auto t1 = quantity{10, deg_C};
auto t2 = quantity_point{quantity{10, deg_C}}; // current design
auto t3 = quantity_point{10, deg_C}; // possible extension with a new constructor overload
With this syntax, I think it gets really clear what we are dealing with in each case.
How do we feel about such an interface?
Received on 2024-06-19 07:52:04