http://d.puremagic.com/issues/show_bug.cgi?id=9872
Summary: format should print class fields
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Andrej Mitrovic <[email protected]> 2013-04-04
00:27:25 PDT ---
This is an unfortunate inconsistency:
import std.stdio;
import std.string;
struct S
{
int x, y;
}
class C
{
int x, y;
}
void main()
{
auto s1 = format("%s", S());
auto s2 = format("%s", new C());
writeln(s1); // S(0, 0)
writeln(s2); // test.C
}
It forces us to either always define a toString() method or call some custom
user-provided formatting function. format() should try to print the values of
the class fields if the toString method is not defined.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------