Errors in specification?
Simen Haugen
simen.haugen at pandavre.com
Thu Jun 12 14:37:23 PDT 2008
This is the property example from http://digitalmars.com/d/1.0/property.html
int a;
int b = 1;
typedef int t = 2;
t c;
t d = cast(t)3;
int.init // is 0
a.init // is 0
b.init // is 1 // Well, I get 0
t.init // is 2 // Well, I get 2
c.init // is 2 // Well, I get 2
d.init // is 3 // Well, I get 2
struct Foo
{
int a;
int b = 7;
}
Foo.a.init // is 0 // Well, I get 0
Foo.b.init // is 7 // Well, I get 0
And another:
enum E { V };
E.V.stringof; // I get int instead of E.V
And another:
float f = 1.0;
f.init; // This should be 1.0 according to the spec.. It's nan here.
const f2 = 1.0;
f2.init; // still nan... Only typedefs changes the init?
Ditto for other types.
And is it possible to check if a float is nan?
float f2;
f2 is float.nan; // false
f2.init is float.init; // false
float.nan is float.nan; // false...
I'm using dmd 1.028
More information about the Digitalmars-d-learn
mailing list