ava/constants.md

30 lines
767 B
Markdown

# Constants
_Constants_ are definitions which provide a name and explicit type for some
[value](values.md). The `const` keyword (definition type) is used to define a
constant.
```
const weak_pi: Float64 is 3.14
const my_name: String is "Pat"
```
In general:
```
const <name>: <type> is <value>
```
Since a constant is categorized as a [definition](general-syntax.md#definitions)
is uses the `is` keyword rather than the `:=` operator.
## Restrictions
Constants are subject to the following restrictions:
- Constants MUST refer to a literal value.
- Constants MUST have an explicit type.
- Constants MAY refer to a record instance.
- Constants CANNOT require a type constructor.
- Constants CANNOT refer to functions.
- Constants CANNOT refer to expressions.