On Tue, 10 Nov 2009 07:49:11 -0500, Justin Johansson <n...@spam.com> wrote:

Don Wrote:

Lutger wrote:
> Don wrote:
> ...
>> There is a definite use for such as thing. But the existing toString() >> is much, much worse than useless. People think you can do something with
>> it, but you can't.
>> eg, people have asked for BigInt to support toString(). That is an
>> over-my-dead-body.
>
> Since you are in the know and probably the biggest toString() hater around: > are there plans (or rejections thereof) to change toString() before D2 turns
> gold? Seems to me it could break quite some code.


I'm hoping someone will come up with a design.

Straw man:

void toString(void delegate(const(char)[]) sink, string fmt) {

// fmt holds the format string from writefln/formatln.
// call sink() to print partial results.

}

That's starting to look like a "serialize" method!

As it should. I should be able to print a 10000 element container without having to load a string representation of 10000 elements in memory.

I'd also like to see the name toString changed to something more appropriate, like output().

And although I think a direct translation is mostly possible, emulating writefln string formatting from tango would be a burden. I don't know if there's any way around it without coming up with some complicated "formatting provider" interface/object implementation, and I don't think it's worth it.

Unfortunately, I doubt Walter accepts this, it's been proposed in the past without success.

-Steve

Reply via email to