[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ex



In article <1993May26.171855.14313@vax.oxford.ac.uk> usher@vax.oxford.ac.uk writes:
>Sorry if my fist try now gets through.
             ^^^^
Sounds painful.  I usually try and use a sledgehammer for postings, myself :-)

>I am trying to find how to export everything from a package.  If a package is
>made at the top level
>
>(defpackage "TEST")
>
>this now has all the function of the top level lisp.  If instead it is set to
>use a different package
>
>(defpackage "TEST" (:use "TEST-1"))
>
>It now only has the functions being exported from TEST-1.  I would like it
>also to have all the lisp functions as well. sort of
>
>(export 'all) 
>(defpackage "TEST" (:USE "TEST-1" "CL-USER"))

You almost got it right with your last line.  Check CLTL2 (p. 271) or your
vendor's Lisp documentation for details, but basically:

In DEFPACKAGE, if you don't specify a :USE option, the package is defined
to :USE some default set of packages; the exact set is
implementation-specific, but usually includes "COMMON-LISP" and,
occasionally, a vendor's specific extension package (e.g. "LCL" for Lucid,
"EXCL" for Allegro).  However, if you do specify a :USE option, your new
package :USE's *only* those packages you indicate; it does *not* include
the defaults as well.  If you also want to :USE the defaults, you must
specify them explicitly.

The problem, of course, is knowing what the default :USE'd packages are.
Since this is is explicitly left unspecified by the standard, I can't tell
you what these ought to be (particularly since I don't know your Lisp
implementation), but you can find out yourself by creating a dummy package
with a default :USE list

    > (defpackage "JUNK")
    #<The JUNK package>

and then examining its :USE'd packages

    > (package-use-list "JUNK")
    (#<The COMMON-LISP package>) ;; or whatever

You can then :USE these packages yourself when declaring your package

    > (defpackage "TEST" (:USE "TEST-1" "COMMON-LISP"))     

The reason your :USE of "CL-USER" didn't work is that "CL-USER" probably
doesn't export the symbols it imports from "COMMON-LISP".

Note that CLTL2 suggests that "portable code should specify (:use
'("COMMON-LISP")) explicitly.", so that your code doesn't quietly depend on
the presence of some default implementation-specific package.

Hope this makes sense.


Pete Halverson                                      INET: halverson@crd.ge.com 
GE Corporate R&D Center                       UUCP: uunet!crd.ge.com!halverson
Schenectady, NY