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).
The following words are interpreted as keywords:
abstractadaptaddraliasandasautobasebreakCorecasechoiceclassconstraintcontinuedefaultdestructorelseexportextendfinalfnforforallfriendifimplimplsimportininterfaceletlibrarylikematchnamespacenotobserveoroverridepackagepartialprivateprotectedrequirereturnreturnedSelfselftemplatethentypevarvirtualwherewhileA word starting with i, u, or f, followed by a decimal integer, is a
numeric type literal.
A word is interpreted as an identifier if it is neither a keyword nor a type literal.
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.
Overview:
Type literals:
Raw identifiers: