Skip to content

Commit

Permalink
document reserved identifiers, use 'identifiers' instead of 'names'
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Jun 19, 2024
1 parent 0384e0d commit a998eb1
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions versioned_docs/version-1.0/language/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ let x = 1
**/
```

## Names
## Identifiers

Names may start with any upper or lowercase letter (A-Z, a-z)
Identifiers may start with any upper or lowercase letter (A-Z, a-z)
or an underscore (`_`).
This may be followed by zero or more upper and lower case letters,
underscores, and numbers (0-9).
Names may not begin with a number.
Identifiers may not begin with a number.

```cadence
// Valid: title-case
Expand Down Expand Up @@ -99,10 +99,31 @@ _#1
!@#$%^&*
```

### Reserved identifiers

The following identifiers are reserved, as they are keywords of the language:

- `if`, `else`, `while`, `for`, `in`, `as`
- `break`, `continue`, `return`
- `true`, `false`, `nil`
- `let`, `var`
- `create`, `destroy`, `emit`
- `fun`, `pre`, `post`,
- `auth`, `access`
- `self`, `init`
- `contract`, `event`, `struct`, `resource`, `interface`,
`entitlement`, `enum`, `mapping`, `attachment`
- `transaction`, `prepare`, `execute`
- `switch`, `case`, `default`
- `import`, `include`
- `require`, `requires`, `static`, `native`, `pub`, `priv`, `try`, `catch`, `finally`,
`goto`, `const`, `export`, `throw`, `throws`, `where`, `final`, `internal`, `typealias`,
`repeat`, `guard`, `is`

### Conventions

By convention, variables, constants, and functions have lowercase names;
and types have title-case names.
By convention, variables, constants, and functions have lowercase identifiers;
and types have title-case identifiers.

## Semicolons

Expand Down

0 comments on commit a998eb1

Please sign in to comment.