On Mon, Feb 11, 2013 at 1:19 PM, Michael <pr@m1xa.com> wrote:
It is possible write something like?

auto force = 2.0 * SI.Newton;
auto energy = force * 2.0 * SI.Meter;



Yes because typeof(2.0 * si.newton) is Quantity!(si.Force) and typeof(force * 2.0 * si.meter) is Quantity!(si.Energy).  In the future when the unit systems are placed in their own modules, you could alias away and say:

auto force = 2.0 * newton;
auto energy = force * 2.0 * meters;

Also note, 'newton' and 'meter' are instances of Unit.  You could define your own and give whatever name you like.  For example:

si.Length myMeter;
auto x = 3.0 * myMeter;
writeln(x);  // prints '3 m'

In std.units I had to make the instances manifest constants (using instanceOf mixin) because they are in structs.  That will probably change in the future if each system is placed in its own module.  In that case std.unit will have to become a package, and I'm not sure if packages are allowed in Phobos. Anyone know?