Google C++ style guide

bearophile bearophileHUGS at lycos.com
Mon Oct 5 09:13:29 PDT 2009


>If you want me to list something that's a little evil, is the automatic silent cast from an integral to its unsigned version. I'd like to disallow such silent cast in D (maybe C# does the same).<

We may even disallow all implicit conversions that lose a significant amount of information:

double => float
real => float
(I think C# requires such casts).

And maybe even (but this is less handy, so I am not sure): real => double

------------------------

Even long => real sometimes loses a little information:

import std.stdio: writeln;
void main() {
    real r = long.min;
    writeln(r, " ", cast(long)r, " ", long.max-cast(long)r);
}

But for now I'm not interested in regulating long => real implicit casts.

Bye,
bearophile



More information about the Digitalmars-d mailing list