[Issue 10828] datetime toString functions should accept sink

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Nov 12 13:34:05 PST 2014


https://issues.dlang.org/show_bug.cgi?id=10828

--- Comment #8 from monarchdodra at gmail.com ---
(In reply to Walter Bright from comment #6)
> I object to creating a same-only-different design instead of using Output
> Ranges.

That's the way it is designed though:
http://dlang.org/phobos/std_format.html#.formatValue

It's documented, does not allocate, supports unicode but does not decode, and
is already rolled out on lots of data types, including (but not limited to)
things like complex. complex even supports custom format flags.

There's a wiki entry:
http://wiki.dlang.org/Defining_custom_print_format_specifiers
And I also believe there are stack overflow articles about how awesome this
design is.

Also, it's not "same-only-different" design, as end users shouldn't actually be
calling "toString": This function is merely a hook for higher order functions
like "format", "to!", "writeln" etc...

So we'd really be doing:
`string toString()` => `void toString(scope void delegate(const(char)[]) sink)`
The old function would be replaced, so there'd be no duplicate function.

At this point, objecting to this change is objecting to Phobos' entire user
defined type to string mechanism.

--


More information about the Digitalmars-d-bugs mailing list