Support %-( ... %) and add documentation. #573

Merged
merged 2 commits into from Jun 6, 2012

Projects

None yet

5 participants

@klickverbot klickverbot and 1 other commented on an outdated diff May 11, 2012
@@ -387,6 +387,26 @@ void main() {
[4 5 6]
[7 8 9]]
</pre>
+
+ Inside compound format specifier, strings and characters are escaped
+ automatically. If you want to stop it, add $(B '-') flag to
@klickverbot
klickverbot May 11, 2012

specifier -> specifiers and If you want to stop it, add -> To disable this behavior/avoid this/…, add the? But since I'm not a native speaker either…

@9rnsr
9rnsr May 11, 2012

In the documentation of std.format, it seems to me that "a compound format specifier" equals to "a pair of two specifiers, %( and %)".
Then, in this case, specifier is better, IMO.
If you wan to stop it -> To avoid this behavior : This is good. Thanks.
add $(B '-') flag -> add the $(B '-') flag : This is difficult... I can't decide which is better...

@klickverbot
klickverbot May 11, 2012

Then I guess it should rather say: »Inside a compound format specifier«… ;)

@9rnsr
9rnsr May 11, 2012

You are right. Thanks!

@jmdavis jmdavis merged commit 53581e7 into dlang:master Jun 6, 2012
@jmdavis
D Programming Language member

Merged.

@denis-sh

Good.

@MartinNowak
D Programming Language member

Yay.

@MartinNowak
D Programming Language member

By the way, what's the state of the undocumented formatElement.
AFAIK we still have no official mean to escape strings/chars.

@denis-sh

What? I'm not the only one who needs this functionality?!

@9rnsr
D Programming Language member

At the time I had added formatElement, it is only used in std.format module. But I did know it would be useful for aggregate field formatting, so I had made it undocumented, instead of marking it 'private'.

As I thought, today it is used in std.typecons.Tuple.toString.

So, I think that changing formatElement to public and documented is enough valuable.

@MartinNowak
D Programming Language member

I've stumbled over these issues when formatting mixin code.
Now that %-(%s %) allows to turn a range of strings into identifiers I'm only missing formatElement to output string literals.

@denis-sh

@dawgfoto, have you seen NG threads mentioned in pull description? Making formatElement public is just a dirty hack and is acceptable only if controlling escaping isn't a common case. As I wrote at NG, I think is's a common case and I do want to control it just like output width etc. Nobody agreed with me (in this or my other thoughts, e.g. about %c) so I decided it's my own need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment