From e30ea7f46285b7d76783348b115d80e840853bd7 Mon Sep 17 00:00:00 2001 From: jonmeow Date: Fri, 16 Aug 2024 14:48:07 -0700 Subject: [PATCH 1/2] Add docs for raw identifier syntax. --- docs/design/lexical_conventions/words.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/design/lexical_conventions/words.md b/docs/design/lexical_conventions/words.md index 34292b1626eda..a7ec27d97f36b 100644 --- a/docs/design/lexical_conventions/words.md +++ b/docs/design/lexical_conventions/words.md @@ -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) @@ -96,12 +97,28 @@ The following words are interpreted as keywords: - `where` - `while` +### Raw identifiers + +A raw identifier looks like `r#`. 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 a keyword 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 `` is not +a keyword, it will refer to the same entity as `r#`. + ## 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) From 1e5a745ddb2c06d54174af7a3bd44871865cadba Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Mon, 19 Aug 2024 07:39:27 -0700 Subject: [PATCH 2/2] Update docs/design/lexical_conventions/words.md Co-authored-by: Chandler Carruth --- docs/design/lexical_conventions/words.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/lexical_conventions/words.md b/docs/design/lexical_conventions/words.md index a7ec27d97f36b..86c4b5f9e6ca5 100644 --- a/docs/design/lexical_conventions/words.md +++ b/docs/design/lexical_conventions/words.md @@ -101,7 +101,7 @@ The following words are interpreted as keywords: A raw identifier looks like `r#`. 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 a keyword in Carbon. +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 `` is not