On Fri, 02 Sep 2011 12:04:08 -0400, Timon Gehr <timon.g...@gmx.ch> wrote:

On 09/02/2011 03:47 PM, Steven Schveighoffer wrote:

The sink type could be aliased. But this is really getting into minor
issues :) The amount of power and performance you get by switching to
writeTo is well worth the extra parameters.


I don't agree those are minor, because this is going into the standard library and should respect all use cases.

Basically, what should be done is:

1. provide an alias void delegate(const(char)[]) Sink; This should be in std.conv; or std.format;, because nobody wants to add it to every single module and if there is a standard way to handle it, no maintenance programmer will be confused by alias.

it needs to go into object.di, because Object needs it.

2. the format parameter should be completely optional in the signature.

This is probably impossible. Just for the object case alone, writeTo need to be declared in Object, which means you'd have to override it with the same parameters.

It's one of the reasons the sink has to stick with one char width.

Because then, writeTo wins not only at the efficiency and flexibility part, but also on the 'pleasant to write' part.

void writeTo(Sink s){ ... }
string toString(){ return ... }

I think this works if you want to ignore the format string:

void writeTo(Sink s, string) {...}

Probably the best we can get.

-Steve

Reply via email to