Program Loading




\begin{emtabbing}
{\bf load}
\it fname \&key \= :verbose \hspace{20mm} \= *load...
...> ''a.out'' \\
\> :print \> nil \\
\> :ld-option \> ''''
\rm
\end{emtabbing}

Load is the function to read either a source file or an compiled object file into the EusLisp process. If the file specified by fname exists, it is loaded. Whether the file is source or binary is automatically checked by seeing its magic number. If the file does not exist but a file with the file type '.o' exists, the file is loaded as an object file. on Sun based systems. Else if a file with the '.l' suffix is found, it is loaded as a source program. Therefore, there is a case where you specified "foo.so" expecting "foo.l" is already compiled, but "foo.l" is actually loaded, since it has not yet been compiled in reality. In other words, if you just specify a base-name of a file, its compiled version is first tried to be loaded, and the source file suffixed by ".l" is tried later. If the file name is not specified in the absolute path by prefixing the name with a slash "/",

load searches for the file in the directories specified by the *load-path* global variable. For example, if *load-path* is ("/user/eus/" "/usr/lisp/"), and "llib/math" is given as fname, load tries to find "/user/eus/llib/math.o", "/usr/lisp/llib/math.o", "/user/eus/llib/math.l" and "/usr/lisp/llib/math.l" in this order. If no appropriate file could be found, an error is reported.

:entry option specifies the entry address to initialize the load module. For example, :entry "_myfunc" option means that the execution begins at _myfunc. Default entry is the basename of the file loaded as described in the section 12.3. Library module names can be specified in :ld-option option string. For example, in order to link a module which uses suncore libraries, :ld-option "-lsuncore -lsunwindow -lpixrect -lm -lc" should be given. On non Solaris systems, ld runs twice when libraries are included; once to determine the size of the linked module, and again to link them actually with a proper memory allocation.

:symbol-input and :symbol-output options are used to solve references from one object module to another or to avoid duplicated loading of libraries. Suppose you have two object modules A and B which has reference to symbols defined in A. You first load the module A specifying :symbol-output = "a.out". Symbol information generated by this linking is written to a.out. In order to load the module B, you have to specify :symbol-input = "a.out" to solve the references from B to A.



On Solaris2 OS, the loading of compiled code is done by calling dlopen in the dynamic loader library. Application of dlopen is restricted to shared objects which are compiled position independently with "-K pic" option. Also, since dlopen cannot open the same file twice, load first does dlclose on the file already loaded.

:print option decides whether load should produce output to *standard-output* for each input expression. This option is provided to find which expression (usually defun, defmethod, etc.) results error in loading.

load-files &rest files [function]

loads files successively with setting :verbose to T.


*modules* [variable]

holds a list of names of the modules that have been loaded so far.


provide module-name [function]
adds module-name in *modules* as the name of the module being loaded. module-name should be a symbol or a string. Calls to require should appear at the beginning of files that compose a complete modules.


require module-name &optional file [function]
loads file unless module-name is found in *modules*. provide and require control dependency among modules and are used to avoid duplicated loading of basic modules. Suppose you have one basic module named "A" and two application modules named "B" and "C" which are independent from each other but rely on "A" module. At the beginning of each file, module name is declared by provide. Since "A" module does not depend on any other modules it does not require anything. (require "A" "a.o") follows calls to provide in "B" and "C". If you load "B" (more precisely, "b.o"), "a.o" is also loaded since it is found in *modules* and two module names "A" and "B" are added to *modules*. Then if you load "C", "A" module is not loaded and "C" is added to *modules*.



\begin{emtabbing}
{\bf system:binload}
\it opath qpath \&optional \=
(entry (pa...
.../bin/eus'') \\
\> (symout ''a.out'') \\
\> (ldopt '''')\\
\rm
\end{emtabbing}

link-load a binary file.


system:txtload fname [function]



k-okada 2013-05-21