Mode declaration

For Edinburgh style programs, you can provide the compiler with modes 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 of 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 means a closed term that cannot be changed by the predicate; f means a free variable; nv means a non-variable term; and d means a don't-know term. The structured mode l(M1,M2) means a list whose head and tail have modes M1 and M2 respectively; the structured mode s(M1,..., Mn) means a compound term whose arguments have modes M1, ..., and Mn respectively.

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



Neng-Fa Zhou 2012-01-03