[Issue 13480] Input range formatting should not format as "elements"

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Sep 16 02:44:55 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13480

Jakob Ovrum <jakobovrum at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #4 from Jakob Ovrum <jakobovrum at gmail.com> ---
(In reply to Kenji Hara from comment #3)
> (In reply to Jakob Ovrum from comment #2)
> > Thanks, nice to know it's possible to work around.
> > 
> > However, I don't think this flag should need to exist.
> > 
> > If strings were simply not quoted, one could get quoting by doing the much
> > more intuitive explicit quoting: `%("%s"%|, %)`. Using '-' is just a hack -
> > it has nothing to do with left-justification and thus the reader has to look
> > it up to know what it does. We should follow the principle of least surprise
> > here, by formatting the string as-is unless quoting is added by the user.
> 
> Handmade quoting is not enough for strings which contain double-quote
> character.
> See:
> 
> import std.stdio;
> void main() {
>   string s = `Hello "D" world!`;
>   writefln("[%(%s%)]", [s]);
> }
> 
> will output:
> ["Hello \"D\" world!"]
> 
> By design, std.format.formatValue functions stringize values by using
> unformattable representation with unformatValue functions by default.
> That's the reason why automatic quoting is done by default.

OK, good point. Thanks for explaining!

--


More information about the Digitalmars-d-bugs mailing list