A system is defined with a defsystem form in an ordinary Lisp source file. This form must be loaded into the Lisp image in order to define the system in the environment. Once loaded, operations can be carried out on the system by invoking Lisp functions, or, more conveniently, by using the system browser.
For example, the expression:
CL-USER 5 > (compile-system 'debug-app :force t)
would compile every file in a system called
Note: When defining a hierarchy of systems, the leaf systems must be defined first -- that is, a system must be declared before any systems that include it.
By convention, system definitions are placed in a file called
defsys.lisp which usually resides in the same directory as the members of the system.
The full syntax is given in defsystem. Below is a brief introduction.
options is a list of keyword-value pairs specifying attributes of the system such as the default location of its member files or the default compiler optimize qualities in effect when compile-system is called.
Options may be specified to defsystem which affect the behavior of the system as a whole. For example,
:package specifies a default package into which files in the system are compiled and loaded if the file itself does not contain its own package declaration. The
:default-pathname option tells the system tools where to find files which are not expressed as a full pathname.
:members keyword to defsystem is used to specify the members of a system. The argument given to
:members is a list of strings. A system member is either a file or another system, identified by a name. If a full pathname is given then the function
pathname-name is used to identify the name of the member. Thus, for example, the name of a member expressed as
System members must have unique names, by a case-insensitive string comparison, so if a system has a member called
"foo" then it cannot have another member (a file or a system) named
The behavior of any member within a system can be constrained by supplying keyword arguments to the member itself. So, for example, specifying the
:source-only keyword ensures that only the source file for that member is ever loaded.
This behavior can be modified by describing dependencies between the members using
. These are specified using the
:rules keyword to defsystem.
The action that is performed if the rule executes successfully.
This is a list of action-member descriptions. The member of each of these descriptions should be either a real system member, or
:previous, which means all members listed before the member of the target in the system description.
If any of these descriptions are already in the current plan (as a result of other rules executing successfully, or as a result of default system behavior), they trigger successful execution of this rule.
:caused-byclause is already in the plan, or
This system compiles and loads members into the
USER package if the members themselves do not specify packages. The system contains three members --
child2 -- which may themselves be either files or other systems. There is only one explicit rule in the example. If
parent needs to be compiled (for instance, if it has been changed), then this causes
child2 to be compiled as well, irrespective of whether they have themselves changed. In order for them to be compiled,
parent must first be loaded.
Implicitly, it is always the case that if any member changes, it needs to be compiled when you compile the system. The explicit rule above means that if the changed member happens to be
member gets compiled. If the changed member is not
parent must at least be loaded before compiling takes place.
(:caused-by (:compile "b"))
causes the instruction compile c to be added to the plan. The compilation of
c.lisp also requires that
a.lisp is loaded, so the instruction load a is added to the plan first. This gives us the following plan:
LispWorks User Guide and Reference Manual - 20 Sep 2017