Speed sp1 = Value<1,0,0> (100)/ Value<0,0,1> (9.8);
// use a shorthand notation:
Speed sp1 = Value (100)/ Value (9.8);
// abbreviate further still:
Speed sp1 = Meters(100)/Seconds(9.8);
Speed sp1 = M(100)/S(9.8);
// this is getting cryptic
Notation matters. SI units are important and should
be supported, but so should a variety of other notions.
The fundamental point here is that we can improve
code quality without adding runtime costs. The use of
a static type system improves code quality by reducing
the number of errors and moves checking to compile
time. In fact, we can move much simple computation to
compile time.
Compile-time computation has been done in a variety
of languages for decades. Before that (and sometimes still)
Do'stlaringiz bilan baham: |