The Avail Programming Language

Values

At execution time, an Avail program may be understood as a stepwise progression of operations on values. Intuitively, a value is a unit of meaning; the number 3, the empty tuple <>, the string "happiness", and the function [x : integer | x + 1] are all values. Dogmatically, a value is an instance of some number of types. Schematically, a value is anything that may be:

  • bound to a constant,
  • stored into a variable,
  • associated with an atom property,
  • associated with a fiber property,
  • accepted by a function,
  • returned by a function,
  • accepted by a method, or
  • returned by a method.

The overwhelming majority of values in Avail are immutable, meaning that neither their structure nor their content are subject to change. It follows that an immutable value should be identityless; having no qualities subject to change, there is no basis for identification of an immutable value that transcends its structure or content. No operations are, or can be, defined that permit a programmer to distinguish between two equal values. Equal values are therefore fungible, that is, interchangeable in every scenario.

This contrasts sharply with traditional imperative programming languages, where only primitive entities like integers are identityless. In more traditional designs, most values are reference values, whether or not they are immutable. Though reference values may have the same structure and content, they may also reside at different locations in memory. This is perfectly natural, except that language features usually provide access to this information. Even if a value's memory location is not directly available, then there is usually a variant of the equality operation that answers whether two values are coincident in memory (and therefore truly "the same"). Access to such information supports the construction of a large class of incorrect programs, but has little utility outside the domain of low-level, system programming. In Avail, values are referentially transparent, meaning that it is not possible to discover whether two equal values reside at the same location in memory.

In Avail, identity is coupled to the capacity to change. Thus only mutable values possess identity. A mutable value has either a flexible structure or impermanent content, and operations are provided to alter each as appropriate. Unlike immutable values, which are compared by structure and content, mutable values are compared only by identity.

Return to Type System | Types ›