@@ -34,8 +34,8 @@ for entities. Different languages make different choices in this space:
3434
3535- Many languages have a set of keywords that are not usable as identifiers,
3636 with no workaround. If this set collides with a name needed by user code,
37- the user is left to solve this problem, often by rewriting the
38- identifier in some way (` klass ` or ` class_ ` ), which sometimes conflicts with the general
37+ the user is left to solve this problem, often by rewriting the identifier in
38+ some way (` klass ` or ` class_ ` ), which sometimes conflicts with the general
3939 naming convention used by the code. And conversely, suboptimal choices are
4040 made for new language keywords to avoid causing problems for existing code.
4141- C and C++ reserve a family of identifiers, such as those beginning with an
@@ -44,7 +44,12 @@ for entities. Different languages make different choices in this space:
4444 library vendors and compiler authors, as well as between implementation
4545 extensions and language extensions.
4646 - MSVC provides a ` __identifier(keyword) ` extension that allows using a
47- keyword as an identifier.
47+ keyword as an identifier. This extension is also implemented by Clang in
48+ ` -fms-extensions ` mode.
49+ - GCC provides an ` __asm__(symbol) ` extension that allows a specific
50+ symbol to be assigned to an object or function, which provides ABI
51+ compatibility but not source compatibility with code that uses a keyword
52+ as a symbol name. This extension is also implemented by Clang.
4853- Python reserves some identifiers but still allows them to be freely
4954 overwritten (such as ` bool ` ) and reserves some identifiers but rejects
5055 assignment to them (such as ` True ` ).
@@ -61,10 +66,11 @@ for entities. Different languages make different choices in this space:
6166 extending this to allow arbitrary non-word-shaped character sequences
6267 between the `` ` `` s.
6368
64- Carbon provides raw identifier syntax, for example ` r#for ` , to allow using
65- keywords as identifiers. Carbon also has strict shadowing rules that mean that
66- predeclared identifiers that are _ not_ keywords are difficult or impossible to
67- redeclare and use in inner scopes.
69+ Carbon provides
70+ [ raw identifier syntax] ( /docs/design/lexical_conventions/words.md#raw-identifiers ) ,
71+ for example ` r#for ` , to allow using keywords as identifiers. Carbon also intends
72+ to have strict shadowing rules that may make predeclared identifiers that are
73+ _ not_ keywords difficult or impossible to redeclare and use in inner scopes.
6874
6975## Principle
7076
@@ -77,7 +83,8 @@ Conversely, when adding language keywords, we will not select an inferior
7783keyword merely to avoid the risk of breaking existing programs. We will still
7884take into account how often it is desirable to use the word as an identifier,
7985including in domain-specific contexts, because that is a factor in whether it
80- would make a good keyword.
86+ would make a good keyword, and will manage the rollout of new keywords to make
87+ it straightforward to migrate existing uses to ` r# ` or a different name.
8188
8289## Applications of this principle
8390
0 commit comments