[Issue 13680] New: Better printing of class instances that don't have a toString
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Tue Nov  4 02:45:58 PST 2014
    
    
  
https://issues.dlang.org/show_bug.cgi?id=13680
          Issue ID: 13680
           Summary: Better printing of class instances that don't have a
                    toString
           Product: D
           Version: unspecified
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Phobos
          Assignee: nobody at puremagic.com
          Reporter: bearophile_hugs at eml.cc
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 at null
test.Foo at 2001FE0 2001FE0
This is useful in debugging and code development, because the address allows to
see what class instances are equal.
--
    
    
More information about the Digitalmars-d-bugs
mailing list