Bug 4762 – Textual representation of struct that doesn't define toString()
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-08-29T15:57:00Z
Last change time
2012-10-21T21:35:01Z
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2010-08-29T15:57:55Z
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