Includes a file contents, which must be valid terms, at the place of occurrence of the directive. The file can be specified as a relative path, an absolute path, or using library notation and is expanded as a source file name. Relative paths are interpreted as relative to the path of the file containing the directive.

When using the reflection API, predicates from an included file can be distinguished from predicates from the main file by looking for the include/1 predicate declaration or predicate definition property. For the included predicates, the line_count/1 property stores the term line number in the included file.

This directive can be used as either a source file directive or an entity directive. As an entity directive, it can be used both in entities defined in source files and with the entity creation built-in predicates. In the latter case, the file should be specified using an absolute path or using library notation (which expands to a full path).


When using this directive as an argument in calls to the create_object/4 and create_category/4 predicates, the objects and categories will not be recreated or redefined when the included file(s) are modified and the logtalk_make/0 predicate or the logtalk_make/1 (with target all) predicates are called.

Template and modes



% include the "raw_1.txt" text file found
% on the "data" library directory:
:- include(data('raw_1.txt')).

% include a "" file in the
% current directory:
:- include('').

% include a file given its absolute path:
:- include('/home/me/databases/').

% create a wrapper object for a Prolog file:
| ?- create_object(cities, [], [public(city/4), include('')], []).