
"Janek Kozicki" <janek_listy@wp.pl> wrote in message news:20060824111220.55aa94f6@absurd...
Matthias Troyer said: (by the date of Thu, 24 Aug 2006 13:17:09 +0900)
Well, as a physicist for me 1 J and 1 Nm are the same. I would reject and never use a library that forces me to distinguish physically identical quantities just because I use a different name for the unit.
fully agree, distinguishing between torque and energy is artificial. And just look how much complications it adds to the library! Whole new concept of anonymous_quantity, serialization (outputting units values) burden, etc...
Displaying a unit using correct unit should be left up for the user - he chooses what name he wants displayed. The library could only take care to correctly convert the value for output requested so that it matches required unit - eg. passed as a string: "kNm","Nm","J","kWh" or "kg m^2 s^-2"
The output of units in Quan is modular, so you don't need to include it if you don't want to You can also work exclusively with anonymous quantities if you prefer. However I believe that the easy ability to get some convenient output feedback in quick tests and examples lowers the entry barrier. The ouput of units is after all a concise description of a quantity. FWIW you can output the units in the default form if you prefer: #include <quan/out/torque.hpp> #include <quan/out/energy.hpp> int main() { quan::torque::N_m torque(1); quan::energy::J energy(1); std::cout << "energy value = " << energy << ", units = " << energy.get_unit() << '\n'; std::cout << "torque value = " << torque << ", units = " << torque.get_unit() << '\n'; } outout: energy value = 1 J, units = kg.m+2.s-2 torque value = 1 N.m, units = kg.m+2.s-2 (BTW note the get_unit function is changed lately from previous versions where IIRC it was just q.units()) regards Andy Little