When I write a significant application in Common Lisp, I organize it into "modules". The Common Lisp standard has a very primitive concept of a "module" that is marked as being deprecated. The functions require and provide are used to manages these modules. But for these modules, there are no provisions for for information hiding which is an essential feature of modules as described in the literature on software engineering.
Since Common Lisp does not provide such essential features of modules, we have to use some different mechanisms. This page describes one way of doing it.
The code for one of our modules will reside in a single operating-system directory. The following sections explain what that directory contains.
There will usually be a single file named module.asd in that directory. The module.asd will contain a single ASDF system definition named module. The name chosen should be unique, so I usually prefix it with the name of the application, like cluffer-simple-buffer for the Cluffer module that contains a simple implementation of its buffer protocol.
The first line of the .asd file is always:
(cl:in-package #:asdf-user)See this text to know why I systematically prefix my in-package with cl:. See this text to know why the file containing the ASDF system definition contains an in-package form at all.
There will usually be a single file named packages.lisp or perhaps package.lisp. It usually contains a single defpackage form. The first line of the file is always:
(cl:in-package #:common-lisp-user)See this text to know why I systematically prefix my in-package with cl:.
The name of the package is usually the same as the name of the ASDF system definition.
The module can then contain an arbitrary number of Common Lisp source files. Each of these files starts with a cl:in-package form, where the package is the one defined in the file packages.lisp.