[Issue 7637] writeln doesn't take custom toString into account

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 20 03:10:35 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7637



--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> 2012-04-20 03:11:31 PDT ---
This is current std.format design, not accepts-invalid bug.

Today, std.format.formatValue (it is internally used by writeln and writefln)
only supports following toString specializations:

http://dlang.org/phobos/std_format.html
----
const void toString(scope void delegate(const(char)[]) sink, FormatSpec fmt);
const void toString(scope void delegate(const(char)[]) sink, string fmt);
const void toString(scope void delegate(const(char)[]) sink);
const string toString();

If there is no toString() that matches required signatures, formatValue formats
the object with 'TypeName(field-formattings-separeted-with-comma)', instead of
reporting 'invalid toString signature detected' error.

There is two design decides:
- Ignoring invalid toString makes more user-defined types formattable.
- Shouldn't prevent any kind of toString that user really wants.

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


More information about the Digitalmars-d-bugs mailing list