Are there any languages that allow units?
You might be interested in F# Units of Measure support
F# has units of measure. Some examples from
http://blogs.msdn.com/andrewkennedy/archive/2008/08/20/units-of-measure-in-f-part-one-introducing-units.aspx
Well the ActiveSupport library for ruby extends the Integer class with methods like hours and days which allows you to write things like:
Time.now + 5.days
But that's not really a syntax feature - it's just a method call and is possible in any language that allows you to add methods to an existing class. You could do it in C# with extension methods - though it would have to be 5.days()
there.
There is a Boost C++ library for Units that makes extensive use of template metaprogramming to provide something similar to the syntax you desire.
quantity<force> F(2.0*newton);
quantity<length> dx(2.0*meter);
quantity<energy> E(work(F,dx));
http://www.boost.org/doc/libs/1_37_0/doc/html/boost_units.html