Skip to content

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented May 8, 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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…

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Thanks!

jmdavis added a commit that referenced this pull request Jun 6, 2012
Support %-( ... %) and add documentation.
@jmdavis jmdavis merged commit 53581e7 into dlang:master Jun 6, 2012
@jmdavis
Copy link
Member

jmdavis commented Jun 6, 2012

Merged.

@denis-sh
Copy link
Contributor

denis-sh commented Jun 6, 2012

Good.

@MartinNowak
Copy link
Member

Yay.

@MartinNowak
Copy link
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
Copy link
Contributor

denis-sh commented Jun 7, 2012

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

@9rnsr
Copy link
Contributor Author

9rnsr commented Jun 7, 2012

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
Copy link
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
Copy link
Contributor

denis-sh commented Jun 7, 2012

@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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants