Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Types and Permissions

This chapter specifies the syntax for types and permissions in Dada.

Types

Named Types

A type may be a simple name: String, i32, bool.

A type may be a dotted path: module.Type.

Generic Application

A type may be applied to generic arguments in square brackets: Vec[String], Pair[i32, bool].

Permission-Qualified Types

A type may be preceded by a permission to form a permission-qualified type: my String, ref Point, mut Vec[i32].

Permissions

The following permission keywords are available:

  • .my my — exclusive ownership.
  • .our our — shared ownership.
  • .ref ref — immutable reference.
  • .mut mut — mutable reference.
  • .given given — a permission supplied by the caller.

Place Lists

The permissions ref, mut, and given may include a place list in square brackets specifying which places they refer to: ref[x, y], mut[self], given[p].

The place list is optional. When omitted, the permission applies without place restrictions.

Generic Declarations

In Type Position

A generic type parameter is declared as type T.

Ambiguity

A single identifier in a generic position is ambiguous between a type and a permission. The ambiguity is resolved during type checking, not parsing.