7.3.4 Using packages in interpreted and compiled code

7.3.4.1 Package rule 1

The most common error that leads to incompatibilities between interpreted and compiled code is sprinklingexport statements throughout several different modules. Consider the following file:

;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: ACE; 
;;;                                            Base: 10 -*-
(in-package "ACE")
(defun dud::worker () ...)
(export 'dud::worker "DUD")

This example clearly shows an attempt to distribute the work of creating the dud package while loading a file that is in theace package. To prevent problems resulting from minor package variations between compile time and load time, theexport command should be in the file that creates thedud package.

Note that the problem with this example is not that the definition of the functionworker, whose name is in thedud package, appears in a file in theace package. Rather, it is that the specification of thedud package was not complete before theace package file was read in and processed; that is,worker was not external. Furthermore, the very way in which the Compiler prints the symbolworker found in the two places in this file is seriously affected by theexport statement at the end of the file. Thus, the compiled file might differ from the interpreted file.


The Advanced User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker