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

Add docs for raw identifier syntax. #4223

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/design/lexical_conventions/words.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

- [Overview](#overview)
- [Keywords](#keywords)
- [Raw identifiers](#raw-identifiers)
- [Alternatives considered](#alternatives-considered)
- [References](#references)

Expand Down Expand Up @@ -96,12 +97,28 @@ The following words are interpreted as keywords:
- `where`
- `while`

### Raw identifiers

A raw identifier looks like `r#<identifier>`. This can be used for identifiers
which have the same spelling as keywords; for example, `r#impl`. It can help
when using C++ code with identifiers that are keywords in Carbon.

The identifier doesn't need to be a keyword, in order to support forwards
compatibility when a keyword is planned to be added. When `<identifier>` is not
a keyword, it will refer to the same entity as `r#<identifier>`.

## Alternatives considered

- [Character encoding: We could restrict words to ASCII.](/proposals/p0142.md#character-encoding-1)
- [Normalization form alternatives considered](/proposals/p0142.md#normalization-forms)
- [Other raw identifier syntaxes](/proposals/p3797.md#other-raw-identifier-syntaxes)
- [Restrict raw identifier syntax to current and future keywords](/proposals/p3797.md#restrict-raw-identifier-syntax-to-current-and-future-keywords)
- [Don't require syntax for references to raw identifiers](/proposals/p3797.md#dont-require-syntax-for-references-to-raw-identifiers)
- [Don't provide raw identifier syntax](/proposals/p3797.md#dont-provide-raw-identifier-syntax)

## References

- Proposal
[#142: Unicode source files](https://github.com/carbon-language/carbon-lang/pull/142)
- Proposal
[#3797: Raw identifier syntax](https://github.com/carbon-language/carbon-lang/pull/3797)
Loading