Mode declaration

For Edinburgh style programs, users can provide the compiler with modes in order to help it generate efficient code. The mode of a predicate p indicates how the arguments of any call to p are instantiated just before the call is evaluated. The mode of a predicate p which has n arguments is declared as
      :-mode p(M1,...,Mn).
where Mi is c (or +), f (or -), nv, d (or ?), or a structured mode. The mode c indicates a closed term that cannot be changed by the predicate; f indicates a free variable; nv inidicates a non-variable term; and d indicates a don't-know term. The structured mode l(M1,M2) indicates a list whose head and tail have modes M1 and M2, respectively; the structured mode s(M1,..., Mn) indicates a compound term whose arguments have modes M1, ..., and Mn, respectively.

Users must declare correct modes. Incorrect mode declarations can be a source of vague bugs., e.g., causing interpreted and compiled programs to give different results.

Neng-Fa Zhou 2013-01-25