7.4. Loading files

Files are loaded from the disk to memory using the load and require functions. The load function loads a Gamma file every time it is called. The require function checks to see if a Gamma file has been loaded, and if not, it loads it. The load_lisp and require_lisp functions do the same thing for files written in Lisp grammar. All of these functions take the name of the file, as a string, for their argument.

As a file is loaded by the Gamma engine, the require mechanism is used to access additional files. This is similar to the #include directive used in C programs, and likewise permits modularization of the application code. Note however that since Gamma is a run-time language, there is no equivalent to object modules of compiled languages. The require function therefore provides the sole mechanism for bringing together modules that define an application.

The pre-defined global variable _require_path_ contains a list of the paths to be searched to find the specified filename. This variable usually references the current directory, and the location for libraries. The list of paths can be augmented with:

_require_path_ = cons ("my_directory_name", _require_path_);
	  

The pre-defined global variable _load_extensions_ contains a list of default extensions that are used by the require functions. Filenames with these extensions do not have to specify the full filename in the require argument. The variable is initialized to (".slg" ".lsp" ""), and can be augmented in the same way as _require_path_.