Skip to content

gh-80143: Clarify use of backslash in string literals #92398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

nw0
Copy link
Contributor

@nw0 nw0 commented May 6, 2022

This reworks the sentence described in the issue. I have omitted the words "special meaning" in favour of "escape sequences" and examples, linking to the table of escape sequences -- I hope this is clearer or at least "plain English".

@bedevere-bot bedevere-bot added docs Documentation in the Doc dir awaiting review labels May 6, 2022
@kumaraditya303
Copy link
Contributor

kumaraditya303 commented May 6, 2022

Docs changes don't require a news entry. You can remove it, I added skip news label.

Copy link
Member

@carljm carljm left a comment

Choose a reason for hiding this comment

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

I think the cross-link to the escape sequences reference is an improvement. I'm not sure that replacing "characters that otherwise have a special meaning" with "characters that may not otherwise appear in the literal" is an improvement. The latter may be misleading, since it could be misunderstood to mean that all characters with escape sequences are otherwise always invalid in string literals. This is not true: e.g. ' can be escaped, but it is also valid unescaped in a string literal enclosed in " or triple-quoted. Similar for newline, which is valid unescaped in a triple-quoted literal.

I think "characters that might not otherwise be allowed in the literal" could work, though tbh I think the existing "characters that otherwise have a special meaning" wording is still just as good or slightly better. It could be improved by clarifying to "characters that otherwise may have a special meaning."

@carljm
Copy link
Member

carljm commented May 7, 2022

I think #92292 is probably a better option here; it also adds the clarification that some escape sequences (like \n) involve characters that otherwise wouldn't be in any way special!

@carljm carljm closed this May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants