From c0d134c2d90aa03a2ab2e75389353524a46c1bb9 Mon Sep 17 00:00:00 2001 From: Paulo Moura Date: Sun, 3 Feb 2019 17:15:39 +0000 Subject: Improve section on compiling and loading source files --- logtalk.html.markdown | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'logtalk.html.markdown') diff --git a/logtalk.html.markdown b/logtalk.html.markdown index 5a52bd3c..ce907ee3 100644 --- a/logtalk.html.markdown +++ b/logtalk.html.markdown @@ -40,7 +40,7 @@ An object encapsulates predicate declarations and definitions. Objects can be cr :- end_object. ``` -# Compiling source files +# Compiling and loading source files Assuming that the code above for the `list` object is saved in a `list.lgt` file, it can be compiled and loaded using the `logtalk_load/1` built-in predicate or its abbreviation, `{}/1`, with the file path as argument (the extension can be omitted): @@ -49,6 +49,11 @@ Assuming that the code above for the `list` object is saved in a `list.lgt` file yes ``` +In general, entities may have dependencies on entities defined in other source files (e.g. library entities). To load a file and all its dependencies, the advised solution is to define a +_loader_ file that loads all the necessary files for an application. A loader file is simply a source file, typically named `loader.lgt`, that makes calls to the `logtalk_load/1-2` +built-in predicates, usually from an `initialization/1` directive for portability and +standards compliance. Loader files are provided for all libraries, tools, and examples. + # Sending a message to an object The `::/2` infix operator is used to send a message to an object. As in Prolog, we can backtrack for alternative solutions: -- cgit v1.2.3