Revenge of the Types
Random question for the type experts out there: is there any language that lets me track the units of my numeric variables? For instance, something like this:<p><pre><code>    float<km> drop(float<m> x0, float<s> duration) {
      float<m> x = x0;
      float<s> t = 0;
      float<m/s> v = 0;
      float<m/s^2> g = -10;
      float<s> dt = 0.01;
      while (t < duration) {
        v += g*dt;
        x += v*dt;
        t += dt;
      }
      return x * (1<km>/1000<m>);  // abbrev for a cast: (float<km/m>).001
    }
</code></pre>
Then I want the compiler to check that I'm not mixing up my units. It seems like this would be really useful, but I've never seen it before.