[phobos] toString
Andrei Alexandrescu
andrei at erdani.com
Sat May 29 07:01:24 PDT 2010
I'm replying to a stream of earlier messages.
Regarding toString etc., I hope to get some work done on that this weekend.
Andrei
On 04/09/2010 08:38 AM, Lars Tandle Kyllingstad wrote:
> Andrei Alexandrescu wrote:
>> On 03/18/2010 10:46 PM, Don Clugston wrote:
>>> (2) Syntax for conversion to string is undecided. Strawman:
>>>
>>> void toString(void delegate(const(char)[]) sink, string format);
>>>
>>> [...]
>>>
>>> Eventually, whatever is chosen will require some changes to
>>> std.format, but I'd just like to get a reasonable first cut for the
>>> initial release.
>>
>> That's fine; we need to look again at std.format anyway.
>
>
> Since Complex needs a toString() function as well, I am wondering: Has
> the above been decided on as the standard for to-string conversion?
>
> I'm asking because the newest part of std.format seems to be
> formattedWrite(), which writes to an output range. Thus, an alternative
> would be
>
> void toString(OutputRange writer, string format);
>
> IMO this seems more flexible, since the sink delegate solution is easily
> implemented as a trivial output range. You can't necessarily do it the
> other way around (for instance, it requires quite a bit of typing if you
> just want toString to fill a buffer array).
>
> Whatever it is, there really should be a standard signature, so that
> library and user types may work seamlessly with the writef*(), format()
> and to!string() functions.
>
> -Lars
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
More information about the phobos
mailing list