On Fri, 02 Sep 2011 19:38:23 -0400, Timon Gehr <timon.g...@gmx.ch> wrote:

On 09/02/2011 07:46 PM, Steven Schveighoffer wrote:
It's arguable that the value of this interface is very low -- currently
it enables things like the builtin sort property on arrays (which I
think should be abolished ASAP), and allows AA's current implementation
(which does not use templates).

I did know that there was some RTTI for the inefficient built-in sort, but I did not know that xtoString is in that interface. So basically, rethinking struct RTTI and changing the compiler to reflect that is the main thing that makes the DIP unpleasant to implement?

Actually, I think yes, that is the main unpleasantness. I wasn't about to suggest in the DIP that we should abolish even part of the RTTI interface for structs, it seems outside the scope.

But now that I think about it, xtoString is probably not used anywhere anymore. I think it used to be used in write* functions when they were not templates. AFAIK, no TypeInfo functions use xtoString, you have to call it directly. The xopCmp, xopEquals, and xtoHash functions all are wrapped by TypeInfo virtual methods.

I'll start a new thread to talk about this. This might make the DIP much easier to implement.



It's actually probably a benefit to stick with char:

1. That's the default output width for streams
2. It's the default width for what most people consider strings (in
fact, the string type).
3. It's pretty simple to convert char[] to wchar[] or dchar[], without
incurring much penalty.

I think the library might be able to, in the future, deal with templated
writeTo, but there are many things that would need changing.

I guess 'properly' supporting wchar and dchar it is not a high priority anyways.

Well, is it more prudent for every printable type to provide a char[], wchar[], and dchar[] version of writeTo, or for the things that call writeTo to provide translations from char[] to wchar[] and dchar[]? In other words, should to!wstring(T) fail if T.writeTo(void delegate(const(wchar)[]) sink, wstring format) is not implemented?

It might be that char[] is used, unless the wchar[] or dchar[] version exists, and then it's used. But I think setting the minimum to providing char[] makes type-implementor's job easier.

-Steve

Reply via email to