From: Alberto Riva
Subject: Exporting the functions defined in a source file
Date: 
Message-ID: <ALB.95Mar21124149@ipvaim.unipv.it>
I have a file that defines several functions in a certain package, and
I want to export all the symbols that name them from that package. Is
it wise and/or correct to do something like the following?

;;; Beginning of source file

(in-package :my-package)

(export (list

  (defun my-fun-1 (...) ...)

  (defun my-fun-2 (...) ...)

...

))

;;; End of source file

It seems to work, but may there be problems? Perhaps when I compile
it?

Thank you,


				   Alberto Riva

				   ···@ipvaim.unipv.it
				   Department of Computer and Systems Science
				   University of Pavia, Italy

				   http://ipvaimed9.unipv.it/
From: David Gadbois
Subject: Re: Exporting the functions defined in a source file
Date: 
Message-ID: <3knu9u$rfd@peaches.cs.utexas.edu>
Alberto Riva <···@ipvaim.unipv.it> wrote:
>I have a file that defines several functions in a certain package, and
>I want to export all the symbols that name them from that package.

In general, messing with the package system is a Big Deal, and it
makes life much easier to do it carefully.  I recommend sticking the
exports in a DEFPACKAGE form in a separate file.  That way the
interface is defined all in one place and you can avoid the potential
problems that can crop up if you fiddle with the package system on the
fly.  However, if you really want to do the exports along with the
function definitions, I would put it up in a macro rather than
wrapping an EXPORT around the top-level definitions (which just looks
like trouble):

(defmacro defexport (name arglist &body body)
  `(progn
     (eval-when (load compile eval)
       (export (intern ,(symbol-name name) ,(symbol-package name))
               ,(symbol-package name)))
     (defun ,name ,arglist ,@body)))

--David Gadbois