Not just for cryptography

bearophile bearophileHUGS at lycos.com
Mon Aug 4 14:01:04 PDT 2008


Era Scarecrow Wrote:
...

An idea is for DMD to:
- when in release mode perform as now
- When not in release mode use 4 byte numbers (or 8 byte on 64 bit CPUs) to compute operations among integral values represented in 1 or 2 bytes, use 8 bytes to perform operations among integral values represented in 4 bytes, and use 16 bytes to perform operations performed among 8 byte integral values. And control if the result can fit in the right range. I think Delphi works almost this way. In Delphi you also can define types of integer intervals:
Smally = 1 .. 25;
so the compiler (if not in release mode) controls if values are in those bounds too.
(In D you can perform something similar adding pre/post that test if that value is in the interval, but such control is done less often and you have to do it yourself manually in many parts of the code, so you don't spot the bug as soon you go out of the bounds).
In some points the compiler doesn't need to control the bounds because it can infer the value will not go out of bounds.

Bye,
bearophile



More information about the Digitalmars-d mailing list