Frits van Bommel wrote:
I usually define something like "void streamTo(Sink sink)" in a base class if I want non-allocating output. Adding a format string to the parameter list should be easy, but I haven't needed it yet. I then usually implement toString by passing an appending Sink to that method, just so Tango's formatting methods will be able to use it.

Yah. The way std.format does it is by operating on an abstract output range, and then have Appender!(T[]) implement the output range interface. So getting stringizing is as easy as passing an Appender!string in there.

IMHO It'd be pretty nice for the standard formatting systems (both the Tango and Phobos ones) to just call a standard Object method taking (Sink sink, char[] format = null) on objects.

Probably we'll need that. You forgot the "in" though :o).


Andrei

Reply via email to