NaNs Just Don't Get No Respect
bearophile
bearophileHUGS at lycos.com
Sun Aug 19 05:08:17 PDT 2012
Walter Bright:
> Oh come on. That's called a "user defined type."
This D code compiles and it throws an "Enforcement failed"
Exception at runtime:
import std.typecons: Nullable;
void main() {
Nullable!int x;
int y = x;
}
With a different type system the compiler makes sure at
compile-time that x is not empty (this means the compiler makes
sure in no code paths x is used before testing it contains
something), avoiding the run-time exception.
Bye,
bearophile
More information about the Digitalmars-d-announce
mailing list