Documenting Prolog Programs

Comments

Comments are introduced with a percent sign %. The rest of the line is ignored by the compiler/interpreter.

Variable Modes

Arguments to a prolog predicate are tradtionally gven modes which determine how they can be used. The following conventions are drwan from the Standard.

These modes are used in documentation.

Examples.

length(+List, ?Len). List is the input argument, Len is a guess argument. This means that length(X,3) can be expected to fail or produce an error.

append has two modes append(?,?,+) and append(+,+,-).

Documenting Predicates

Here is an example of the documentation of a typical predicate.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	append(+List1, +List2, -List3)
%	append(?List1, ?list2, +List3)
%
%	append(L1,L2,L3) is true when L3 is the list obtained
%	by appending L2 to L1. Thus append([1,2], [3,4,5], [1,2,3,4,5])
%	is true.
%


Return to UG AI home page

Last Changed: 2 August 1995