Loading Code with cl-lite

<-Previous | ^UP^ | Next->

In previous topics, we have seen that there is some requirement to manage the load order. With small numbers of source files this is manageable manually, but once the number of source files exceeds maybe 5 or 6, this becomes an onerous and somewhat tedious task

GendL has a utility to support this called cl-lite. It can be called from either the REPL or it can be initiated from the init file (gdlinit.cl). cl-lite supports the following features

  • It will load any .lisp file found in any source directory below the target directory. So in the example codebase on the right, if cl-lite was applied to the airplane directory it would load .lisp files from source, common/source, engine/source, fuselage/source and wing/source
  • The order in which directories are loaded may be specified at any level using a system-ordering.isc file
  • The order in which files in a source folder are loaded may be specified for that source directory in a file-ordering.isc file
  • Directories or files to be ignored can be specified in an ignore-list.isc file

The structure of the system-ordering.isc, file-ordering.isc and ignore-list.isc is identical; it is a literal list of strings identifying target folders or files. Note that ignore-list.isc may apply to either directories or files whilst system-ordering.isc only applies to directories and file-ordering.isc only applies to files

Executing cl-lite

cl-lite takes a pathname argument. The pathname may be a string or a logical pathname

(cl-lite "/codebase/airplane")

If we wanted to enforce a load order for the directories we would use the system-ordering.isc file. In this example, assuming multiple packages which mirror the directory structure, we would probably want to load common first, then engine, wing and fuselage (since they would :use the :airplane-common package) and lastly the source directory since it would :use all of the previously defined packages. So system-ordering.isc would look like this

("common" "wing" "fuselage" "engine" "source")

Assuming each of the folders has a package file, we would want to load that as the first file when the directory is loaded, so each source folder would have a file-ordering.isc file like this


2 things to note here

  • There is no need to specify the file extension
  • There is only a requirement to specify files which have special load order, any other files in the folder are loaded by default in alphabetical order

Finally, if for some reason we wished to suppress the load of the engine module, we would use the ignore-list.isc file in the airplane directory as shown below