Libraries

Libraries contain modules. For example, the Dylan library contains the Dylan module described earlier, the Extensions module, and possibly several other implementation-dependent modules. Note that a library and a module may share a given name. Modules with the same name may also appear in more than one library.

By default, a Dylan environment provides a library called Dylan-User for the convenience of the programmer. This is typically used for short, single library programs which depend only on modules found in the Dylan library.

Additionally, every library contains an implicit module, also known as Dylan-User, which imports all of the modules found in the Dylan library. This may be used for single module programs. Many Dylan environments, however, use it to bootstrap new library definitions. The vehicle library, for example, might be defined as follows in a Dylan-User module:

define library Vehicles
  use Dylan;            // This is the library!
  export                // These are modules.
    Vehicles,           // (Defined above.)
    Traffic-Simulation,
    Crash-Testing,
    Inspection;         // (Hypothetical.)
end library Vehicles;
      

This library could in turn be imported by another library:

define library Vehicle-Application
  use Dylan;
  use My-GUI-Classes;
  use Vehicles;
end;
      

Libraries import other libraries and export modules, whereas modules import other modules and export variables. In general, a module may import any module found in its own library or exported from a library imported by its own library. The following module, for example, could belong to the Vehicle-Application library.

define module Sample-Module
  // module name         source library
  use Dylan;          // Dylan
  use Extensions;     // Dylan
  use Menus;          // My-GUI-Classes
  use Vehicles;       // Vehicles
  use Inspection;     // Vehicles
end module;