I think it's more errors in derivations that you're after. Like the sibling comment mentions, in physics you get a bunch of different units but they have to be consistent, eg despite there being different expressions that describe energy, they end up being the same under the hood.
I'm not sure I can think of a case where you can do otherwise.
Entropy is J/K and seems to follow the same dimensionality constraints as everything else, though I'm not well versed in information theory so I don't know how they think about it.
The log example only works because log only takes a dimensionless parameter. The only way to get that is to cancel the two kinds of meters and shove the dimensionless 0.007 into it. Ie it is a type error to take the log of 7mg or anything with a unit.
One interesting thing I came across is in the cpp book by Stroustrup he actually builds a custom type system capable of preventing issues like this and uses physics examples.
I'm not sure I can think of a case where you can do otherwise.
Entropy is J/K and seems to follow the same dimensionality constraints as everything else, though I'm not well versed in information theory so I don't know how they think about it.
The log example only works because log only takes a dimensionless parameter. The only way to get that is to cancel the two kinds of meters and shove the dimensionless 0.007 into it. Ie it is a type error to take the log of 7mg or anything with a unit.
One interesting thing I came across is in the cpp book by Stroustrup he actually builds a custom type system capable of preventing issues like this and uses physics examples.