*Should* char[] be an output range?

monarch_dodra monarchdodra at gmail.com
Mon Sep 2 01:04:20 PDT 2013


I'm finalizing work on improvements to "put". The main
improvement is that put will now be able to transcode on the fly,
allowing it to do things such as putting a dchar into char sink.

What this means is that "(const(char)[]){}" is now considered an
output range for dchar. This wasn't the case before, and a source
of bugs in functions like formattedWrite: They didn't get much
visibility, since Appender (the sink of choice for tests) can do
it natively. But passing a delegate char sink to formattedWrite
often ended in error.

In any case, my main question is:

*currently*, "char[]" isn't considered an output range. Shouldn't
it though? The rationale is that it contains dchar elements, and
we don't know how to "put" a dechar in a char[]'s front. But we
do now.

Was this just an implementation restriction? Or is there a real
good reason to not allow it?

In my code, it's a one line tweak to "unlock" char[] as a full
fledged output range for char/wchar/dchar/string/wstring/dstring.
Should I do it?


More information about the Digitalmars-d mailing list