Comment #0 by bearophile_hugs — 2012-04-08T17:23:23Z
D2 code:
import std.stdio;
class Foo {}
void main() {
Foo[] bar = [null, new Foo];
foreach (f; bar)
writeln(f);
}
Output, DMD 2.059beta3:
null
test.Foo
But the first null is a Foo class empty reference, it's not just a null. So I'd like writeln to print more information about the type of the null, with an output like this:
cast(Foo)null
test.Foo
Or:
cast(test.Foo)null
test.Foo
If you want similar output is useful for structs too:
import std.stdio;
struct Foo {}
void main() {
Foo* f;
writeln(f);
}
Currently prints:
null
But a better and more informative output may be:
cast(Foo*)null
Or:
cast(test.Foo*)null
Inside collections probably "null" is enough still, to avoid a too much long output:
import std.stdio;
struct Foo {}
void main() {
Foo*[] a = [null, null];
writeln(a);
}
Current output, acceptable:
[null, null]