next up previous contents index
Next: Determinacy declaration Up: Directives Previous: Directives   Contents   Index

Mode declaration

For Edinburgh style programs, the programmer 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$,$\ldots$,$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 (uninstantiated) 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,\ldots Mn)$ means a compound term whose arguments have modes $M1$, ..., and $Mn$ respectively.



Neng-Fa Zhou
1999-11-24