ava/constants.md

767 B

Constants

Constants are definitions which provide a name and explicit type for some value. 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 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.