Files
carbon-lang/docs/design/lexical_conventions/words.md
T
josh11b e4595deb4b Clarify rules around Self and .Self (#2107)
A number of smaller changes grouped together in one proposal:

-   Make `Self` a keyword.
-   Clarify that `Self` refers to the current type in a base class and in impl declarations.
-   Clarify when `.Self` is legal, and what type it has.
-   Also specify that `where` is not an associative operator.
2022-09-08 13:04:58 -07:00

1.7 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.

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.

Keywords

The following words are interpreted as keywords:

  • abstract
  • addr
  • alias
  • and
  • api
  • as
  • auto
  • base
  • break
  • case
  • class
  • constraint
  • continue
  • default
  • else
  • extends
  • external
  • final
  • fn
  • for
  • forall
  • friend
  • if
  • impl
  • import
  • in
  • interface
  • is
  • let
  • library
  • like
  • match
  • namespace
  • not
  • observe
  • or
  • override
  • package
  • partial
  • private
  • protected
  • return
  • returned
  • Self
  • then
  • var
  • virtual
  • where
  • while

Alternatives considered

References