On Thu, 18 Nov 2010 10:53:20 -0500, Steven Schveighoffer wrote:

> On Thu, 18 Nov 2010 10:44:00 -0500, Nick Sabalausky <[email protected]> wrote:
> 
>> I like it, *provided that* there's a quick-and-easy way to just get a
>> string
>> when that's all you want. At the very least there should be a standard
>> sink
>> function that's a default argument to toString that just simply builds
>> a string. What we definitely *don't* want is for the user to ever have
>> to write their own sink delegate just to get a string (which I've had
>> to do with Tango on occasion).
> 
> to!string(x);
> 
> (which will probably do the delegate/etc when x.toString is defined)

On the Phobos list, Andrei suggested a unified toString signature, which 
I tried out for std.complex.Complex:

  // If sink is provided, output to it and return null,
  // otherwise return string.
  string toString(void delegate(const(char)[] ) sink = null,
      string fmt = null) { ... }

But I don't know, one might as well just define a separate toString().  I 
prefer the to!string() solution you suggest.

-Lars

Reply via email to