The possible argument modes are:
+
++
-
?
:- mode p(+), q(-), r(++, ?).As the operator binds less than comma, the argument of mode/1 might have to be parenthesised when it is followed by other goals. Modes must be declared in a predicate's definition module. Modes are significant only for the first 15 arguments, for higher arguments the mode is always taken as ?.
NOTE: If the instantiation of a runtime predicate call violates its mode declaration, no exception is raised and its behaviour is undefined.
The declared mode information can be accessed by retrieving the predicate's 'mode' property with get_flag/3.
Success: % code size: % no mode declarations [eclipse]: [append]. /home/eclipse/src/append.pl compiled 212 bytes in 0.03 seconds % mode for one argument decreases the code size [eclipse]: mode(append(++, ?, ?)), [append]. /home/eclipse/src/append.pl compiled 120 bytes in 0.00 seconds % modes for other arguments further decreases the size [eclipse]: mode(append(++, ++, -)), [append]. /home/eclipse/src/append.pl compiled 92 bytes in 0.00 seconds % size of the trail stack cygnus% cat p.pl p(f(1), [output]) :- !. p(f(2), [another_one]). test :- p(f(1), X), statistics(trail_stack_used, T1), writeln(T1). :- test. cygnus% eclipse [eclipse]: [p]. 16 /home/eclipse/p.pl compiled 540 bytes in 0.02 seconds % With modes the code is shorter and does less trailing [eclipse]: mode(p(++, -)), [p]. 12 /home/eclipse/p.pl compiled 408 bytes in 0.02 seconds % bad mode declaration: [eclipse]: mode(p(+)), [user]. p(a). user compiled 40 bytes in 0.00 seconds yes. [eclipse]: p(X). % call violates the mode declaration no (more) solution. Error: mode p(X). (Error 4). mode p(+), get_flag(p/1, mode, X). (Error 5). % equivalent to mode((p(+), get_flag(p/1, mode, X)))