Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better printing of class instances that don't have a toString #10095

Open
dlangBugzillaToGithub opened this issue Nov 4, 2014 · 0 comments
Open

Comments

@dlangBugzillaToGithub
Copy link

bearophile_hugs reported this on 2014-11-04T10:45:58Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=13680

Description

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.
@thewilsonator thewilsonator removed OS:Windows Issues Specific to Windows Arch:x86 Issues specific to x86 P4 labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants