23.04.2012 21:15, kenji hara написал:
2012年4月24日1:14 Denis Shelomovskij<verylonglogin....@gmail.com>:
23.04.2012 18:54, kenji hara написал:

Please give us use cases. I cannot imagine why you want to
change/remove quotations but keep escaped contents.


Sorry, I should mention that !' and !" are optional and aren't commonly
used, and all !?* are very optional and are here just for completeness
(IMHO).

An example is generating a complicated string for C/C++:
---
myCppFile.writefln(`tmp = "%!?"s, and %!?"s, and even %!?"s";`,
                   str1, str2, str3)
---


--
Денис В. Шеломовский
Denis V. Shelomovskij

During my improvements of std.format module, I have decided a design.
If you format some values with a format specifier, you should unformat
the output with same format specifier.

Example:
     import std.format, std.array;

     auto aa = [1:"hello", 2:"world"];
     auto writer = appender!string();
     formattedWrite(writer, "%s", aa);

     aa = null;

     auto output = writer.data;
     formattedRead(output, "%s",&aa);  // same format specifier
     assert(aa == [1:"hello", 2:"world"]);

More details:
     
https://github.com/D-Programming-Language/phobos/blob/master/std/format.d#L3264

I call this "reflective formatting", and it supports simple text based
serialization and de-serialization.
Automatic quotation/escaping for nested elements is necessary for the feature.

But your proposal will break this design very easy, and it is
impossible to unformat the outputs reflectively.

For these reasons, your suggestion is hard to accept.

Kenji Hara

Is there sum misunderstanding?

Reflective formatting is good! But it isn't what you always want. It is needed mostly for debug purposes. But debugging is one of two usings of formatting, the second one is just writing something somewhere.

There are already some non-reflective constructs (like "%(%(%c%), %)" for a range and "X%sY%sZ" for strings) and I just propose adding more comfortable ones because every second time I use formatting I use it for writing (I mean not for debugging).

--
Денис В. Шеломовский
Denis V. Shelomovskij

Reply via email to