Issue 13680 - Better printing of class instances that don't have a toString
Summary: Better printing of class instances that don't have a toString
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Windows
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-04 10:45 UTC by bearophile_hugs
Modified: 2024-12-01 16:22 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2014-11-04 10:45:58 UTC
This program shows the current default printing of class instances (dmd 2.067alpha):


class Foo {}
void main() {
    import std.stdio;
    Foo f;
    f.writeln;
    f = new Foo;
    writeln(f, " ", cast(void*)f);
}


Output:

null
test.Foo 2001FE0


But perhaps it's better for D writeln to print class instances (that don't have a toString) more like Java:

test.Foo@null
test.Foo@2001FE0 2001FE0


This is useful in debugging and code development, because the address allows to see what class instances are equal.
Comment 1 dlangBugzillaToGithub 2024-12-01 16:22:51 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10095

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB