Escaping control in formatting
Denis Shelomovskij
verylonglogin.reg at gmail.com
Tue Apr 24 01:20:04 PDT 2012
On Tuesday, 24 April 2012 at 04:55:34 UTC, kenji hara wrote:
> My concern is that the proposal is much complicated and less
> useful
> for general use cases.
> You can emulate such formatting like follows:
IMHO addition of %!+s and %!-s alone and removing %c's magic will
only simplify formatting for the user. It was hard (for me) to
understand current escaping rules because it's undocumented and
looks dissonant (for me) because of the fact that escaping is a
part of formatting but user is unable to control it unless
magical %c is used.
I agree that !', !", and !?* of course aren't commonly used as I
have already written. Personally I don't need them at all.
But this is a common pattern for me: `xformat("My pets: %(%!-s,
%)", petsAsStrings)`. And "My pets: %(%(%c%), %)" is too
complicated, dissonant and not general (will not work if I'll
give it pets as int[] e.g.) that I never use it. I use
`.joiner(", ")` instead and every time I do it I think that
something is really wrong with array formatting in Phobos.
--
Денис В. Шеломовский
Denis V. Shelomovskij
More information about the Digitalmars-d
mailing list