Skip to content
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

spec: should octal escape sequences in string literals accept an "o" prefix? #30225

Closed
josharian opened this issue Feb 14, 2019 · 4 comments
Closed
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. v2 A language change or incompatible library change
Milestone

Comments

@josharian
Copy link
Contributor

This is a minor follow-up to #19308; I've started a new issue since that one is long, and this is a corner case.

In the String literals section, the spec says:

The three-digit octal (\nnn) and two-digit hexadecimal (\xnn) escapes represent individual bytes of the resulting string [...] inside a string literal \377 and \xFF represent a single byte of value 0xFF=255

Given that we are moving towards using 0o for octal integers, and given that hexadecimal escaping in string literals begins \x, should string literals also accept a \o prefix for octal bytes?

I suspect that so few people use octal byte escape sequences in string literals that it's not worth changing for consistency, but I thought it worth making an explicit decision about.

cc @griesemer @rsc @ianlancetaylor

@josharian josharian added v2 A language change or incompatible library change NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Feb 14, 2019
@josharian josharian added this to the Go1.13 milestone Feb 14, 2019
@robpike
Copy link
Contributor

robpike commented Feb 14, 2019

I can't remember even seeing an octal string escape in the wild. Everyone uses \x or \u. I don't think it's worthwhile. String literals are complicated enough already.

@griesemer
Copy link
Contributor

Agreed. I don't think we should touch string and rune escapes.

@josharian
Copy link
Contributor Author

Great. I'll call this decided; thanks.

@ianlancetaylor
Copy link
Contributor

To the best of my knowledge and research ability the only languages that support a string literal octal escape of the form "\oDDD" are Perl (in the form \o{DDD}) and Haskell. Languages like Rust and Swift don't even support the form \DDD that we copied from C, and only support hex (Rust) and Unicode (Rust and Swift) escapes. So I don't see much reason to add "\oDDD" to Go.

@golang golang locked and limited conversation to collaborators Feb 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. v2 A language change or incompatible library change
Projects
None yet
Development

No branches or pull requests

5 participants