[Openmcl-devel] Docs on defpackage, in-package, use-package, provides and require

Hamilton Link hamlink at comcast.net
Tue Aug 17 03:24:11 UTC 2004



On Aug 16, 2004, at 1:35 AM, Andrew P. Lentvorski, Jr. wrote:

> Could someone point me to some OpenMCL documentation on how and when 
> to use the various package and module stuff?  I read Erann Gat's "The 
> Complete Idiots Guide to Common Lisp Packages", but I still don't 
> understand how it all goes together.
>

Aside from the common lisp hyperspec or cltl2, I can't point you to 
docs, but I can help you set up your package definitions if that's your 
problem.

> Specifically, I am trying to get "clos-unit" to work as a package, but 
> I seem to be missing something.  I would like to do something like:
>
> (load "clos-unit")
> (use-package :clos-unit)
>
> or just:
>
> (require :clos-unit)
>
> and have it all work.
>

If you want (use-package :clos-unit) to work after (load "clos-unit"), 
clos-unit.lisp should have (in addition to the code that's already 
there) some preamble along the lines of:

(in-package :cl-user)
(unless (find-package "CLOS-UNIT")
   (defpackage "CLOS-UNIT"
     (:nicknames :unit)
     (:export "API-FN1"
              "API-CLASS-FOO"
              "ETC.")) ; ... plus maybe some more API, and a package-use 
list or import lists depending on the functionality that clos-unit 
depends upon
   )

(in-package :clos-unit)
;; all your code for clos-unit goes here

Then when you load the file, it will ensure that the package exists, 
define everything, and export the API you want clos-unit to provide 
when use-package is called from somewhere. Really that somewhere will 
often be in the context of some other package defining some other 
library API, in which case the defpackage for that other API will be 
where the package use is declared, or where particular bits of the 
clos-unit API is imported.

For require to work you have to have the clos-unit.lisp file in a 
directory that the require function looks, but it is only equivalent to 
load, and will not use-package anything into anywhere afaik.

Is that the kind of help you had in mind?

h

> Thanks,
> -a
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>




More information about the Openmcl-devel mailing list