www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4762] New: Textual representation of struct that doesn't define toString()

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4762

           Summary: Textual representation of struct that doesn't define
                    toString()
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-08-29 15:57:55 PDT ---
This D2 program:


import std.stdio: writeln;
struct Foo { int x; string s; }
void main() {
    Foo f = Foo(1.5, "hello");
    writeln(f);
}


With DMD 2.048 it prints:
Foo


When a struct doesn't define a toString() I'd like (mostly for debugging
purposes) writeln/format to create a bit better textual representation, for
example it may show fields values:

Foo(x=1.5, s="hello")


See also bug 3813

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 29 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4762


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 21 2012