How to have strongly typed numerical values?
Don Clugston
dac at nospam.com
Wed Sep 5 00:18:36 PDT 2012
On 05/09/12 03:42, bearophile wrote:
> Nicholas Londey:
>
>> for example degrees west and kilograms such that they cannot be
>> accidentally mixed in an expression.
>
> Using the static typing to avoid similar bugs is the smart thing to do :-)
I'd be interested to know if that idea is ever used in real code. I
mean, it's a classic trendy template toy, but does anyone actually use it?
I say this because I've done a lot of physics calculation involving
multiple complicated units, but never seen a use for this sort of thing.
In my experience, problems involving units are easily detectable (two
test cases will catch them all).
The most insidious bugs are things like when you have used constants at
25'C instead of 20'C, or when you have a sign wrong.
More information about the Digitalmars-d-learn
mailing list