Ellery Newcomer wrote:
On 03/09/2010 05:53 AM, Steven Schveighoffer wrote:
On Mon, 08 Mar 2010 17:52:25 -0500, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> wrote:


Printing values with spaces between them is entirely fine for e.g. all
numbers.


You know what, you are right. Why should phobos cater to people wanting
to print something as arcane as a string array, or a multi-dimensional
array. People have no business using such constructs, they should be
punished by having to write their own routines.

It's all one-dimensional arrays of numbers for me from now on!

-Steve

and formatted in hex

In wake of printing multi-dimensional arrays, I agree that start and end delimiters should be present by default. If delimiters are present, it only makes sense to make the array look like a D array, so the ", " becomes an acceptable proposition.

I'm unsure about strings - should "to" go all gung-ho on quoting and escaping quotes etc.? That's a bit odd. Consider:

auto str = to!string("hello world");

I'd expect the call to be an identity application that makes str equal to "hello world". So far so good. Then say I convert with "to" an array of strings to a string:

auto str2 = to!string(["hello world"]);

Now str2 is "\"hello world\"", i.e. has an extra pair of quotes. So "to" applied to an array does not always use "to" applied to each element of the array - it has a completely different behavior. I wonder whether that's a desirable behavior.

(For the record, I agree that there are ambiguities if the quotes are not added and escaped etc. I just wonder whether that should be part of "to"s charter.)

Another thing that's unclear to me is whether writeln and "to" should be defined such that

write(to!string(stuff))

and

writeln(stuff)

produce the same text. Currently that's the general plan, but I wonder whether we should change the approach.


Andrei

Reply via email to