The last time I had to remind you of this was March 31st. Permission to
quote any part of any message I post, without proper attribution, is
denied. Your unjustified fear of being held responsible for falsely
attributing quoted text to someone using a spoofed user id doesn't
excuse you from your responsibility for properly attributing quotations.
There is not anything necessarily wrong with doing that multiplication,
but when you assign the result of it to a variable with incompatible
units, the compiler could raise an error.
That's why I listed assignment as one of the contexts where there is a
constraint requiring matching units (for those entering this discussion
late, I'm not talking about a C constraint; just a requirement for the
calculation to be meaningful).
....
One problem this brings up is that you need to support constants
with units, and the physics book wasn't always careful to put units
on its constants. Formulas you find elsewhere are even less likely
to identify the units involved, but just state the units of all the
variables and the result.
Two of the key things I learned in physics classes at Caltech were the
importance of associating both units and uncertainties with every
quantity. My real world experience has been that the actual scientists I
work with are extraordinarily lax about such things, which often causes
problems.
Two weeks ago I asked someone to determine whether there was any
evidence of a significant impact on the accuracy of our measurements
correlated with a particular event. Yesterday, I got a response that was
just a bunch of raw numbers, with no uncertainties, and not even a
qualitative assessment of their significance. I asked him, to at least
give me a statement about whether or not he thought it was significant.
His response was more numbers: comparable figures from last year, again
with no uncertainties and no verbal assessment of the significance of
the difference between last year's figure and this year's. I don't have
the authority to insist that he give me a more useful response, and I
have neither the data nor the time required to do that analysis myself.
I suspect he doesn't really understand what the term "statistically
significant" means. I had to tell our client "we don't know".
Another problem is that you really need to handle unit-generic
routines, like printf() and strtod(). Quick, what's the printf
format for a floating point number in furlongs per fortnight?
In a C-like system where types had units attached, printf("%f") would
need to be able to print any type whose promoted type is based upon
double, regardless of units. There would also be a need for some
mechanism for accessing a string representing the units - perhaps a
_unitsof operator, analogous to sizeof?
I suppose some applications will demand that you add 'currency' as
a 6th fundamental unit. ...
No, you need a different unit for each currency.
A unit-based system will be nearly useless unless arbitrary user-defined
units can be defined. Chemical calculations, for instance, often need to
distinguish between "moles of Carbon atoms" and "moles of Hydrogen
atoms". You'd better NOT cancel those out just because they're both
moles - you need to apply a context-specific conversion factor, such as
4 Hydrogen atoms/Carbon atom, for Methane, in order to get proper
cancellation.
In other contexts, units of "cookies" or "divisions" or "tables" might
be appropriate.
....
Then we were introduced to the "CGS" system (centimeter, gram,
second), which somehow managed to call the speed of light a
dimensionless constant of 1. I never did like that.
The CGS system does not make the speed of light 1. You're thinking of
Plank units. They're very convenient when you would otherwise find
yourself using equations with a lot of 'c's in them, but the absence of
units can make it easy to get lost in such calculations.