[Issue 7866] New: Type printing too for single nulls
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Apr 8 17:22:42 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7866
Summary: Type printing too for single nulls
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2012-04-08 17:23:23 PDT ---
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]
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list