RFC: Units of measurement for D (Phobos?)

Nordlöw via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 17 05:51:28 PDT 2016


On Wednesday, 16 March 2016 at 22:34:04 UTC, David Nadlinger 
wrote:
> What you can do is to take an arbitrary quantity with an 
> (angle.canConvert!radian) template constraint. Inside the

I believe `isConvertableTo` is a more Phobos-compliant naming, 
right?

Is there are reason why `convert` wasn't named the shorter and 
Phobos-compliant `to` instead?

Was this prior to `std.conv.to`?

> function, you then simply use cos(angle.convert!radian / 
> radian) or whatever.

Why not simply add a Quantity member

     auto ref toValue() const

used as

     cos(angle.to!radian.toValue)

Shorter and puts less stress on the compiler.


More information about the Digitalmars-d mailing list