Updates the documentation under `docs/design/` to use `ref` instead of `addr` after their removal in #5434. Care was taken to manually clean up edge cases and, in a couple cases, surrounding text (see 3d72c49bb75c0f40ca7e8114b6a1369b941e1697). After this change, there are no matches for `addr(?!ess)` in `docs/design/`. Closes #6032
4.3 KiB
Words
Table of contents
Overview
A word is a lexical element formed from a sequence of letters or letter-like
characters, such as fn or Foo or Int, optionally preceded by r#.
The exact lexical form of words has not yet been settled. However, Carbon will follow lexical conventions for identifiers based on Unicode Annex #31. TODO: Update this once the precise rules are decided; see the Unicode source files proposal.
Carbon source files, including comments and string literals, are required to be in Unicode Normalization Form C (NFC).
Keywords
The following words are interpreted as keywords:
abstractadaptaliasandasautobasebreakCorecasechoiceclassconstraintcontinuedefaultdestroyelseexportextendfinalfnforforallfriendifimplimplsimportininterfaceletlibrarylikematchnamespacenotobserveoroverridepackagepartialprivateprotectedrefrequirereturnreturnedSelfselftemplatethentypevarvirtualwherewhile
Type literals
A word starting with i, u, or f, followed by a decimal integer, is a
numeric type literal.
Identifiers
A word is interpreted as an identifier if it is neither a keyword nor a type literal.
Raw identifiers
A raw identifier is a word starting with r#. A raw identifier is equivalent
to the word following the r# prefix, except that it is always interpreted as
an identifier, even if it would otherwise be a keyword or type literal.
Raw identifiers can be used to specify identifiers which have the same spelling
as keywords; for example, r#impl. This can be useful when interoperating with
C++ code that uses identifiers that are keywords in Carbon, and when migrating
between versions of Carbon.
The word doesn't need to be a keyword, in order to support forwards
compatibility when a keyword is planned to be added. If word is an identifier,
then word and r#word have the same meaning.
Alternatives considered
Overview:
Type literals:
- Use C++ type keywords with LP64 convention
- Use full type name with length suffix
- Use uppercase for type names
- Support additional bit widths
Raw identifiers:
- Other raw identifier syntaxes
- Restrict raw identifier syntax to current and future keywords
- Don't require syntax for references to raw identifiers
- Don't provide raw identifier syntax
References
- Proposal #142: Unicode source files
- Proposal #2015: Numeric type literal syntax
- Proposal #3797: Raw identifier syntax