Re: How to Easily Specify Export Symbol



In general you cannot mix and match easily.

You can have a look at tfb's "conduit" packages to achieve what you want.

http://www.tfeb.org/lisp/hax.html

Cheers
--
Marco




joesb wrote:
Hi,

I was developing my own little package shadowing some of LISP function
to be generic (<, >, equal, etc.).

So in my package.lisp, I have

(defpackage :cl-oo
  (:use :common-lisp)
  (:shadow :< :> :equal ...)  ; Only list the symbol that I shadow
  (:export :< :> :equal ...)) ; Only list the symbol that I shadow

Now when I want to use this package, I thought I would do

(defpackage :my-app
  (:use :common-lisp :cl-oo))

Surely this won't work, A condition will be signaled because symbol in
:cl-oo and common-lisp conflict.

I could have fixed this by declare the shadowing symbol.

(defpackage :my-app
  (:use :common-lisp :cl-oo)
  (:shadowing-import-from :cl-oo :< :> :equal ...))


But I don't want to repeat myself again like that. I want to be able to specify once somewhere, that, if these two packages are use together, symbols from :cl-oo package will shadow those in :common-lisp packages.

Only way I see is

(defpackage :cl-oo-wrapper
  (:import-from :common-lisp :defun :defmacro ...) ; All Symbol not
shadow by :cl-oo
  (import-from :cl-oo :< :> :equal ...) ;All symbol exported by :cl-oo,
and much more.
  (:export :defun :defmacro :< :> ...)) ;Merge of Symbols above

Then I can use this package

(defpackage :my-app
   (:use :cl-oo-wrapper))

But is the the best way to do it?
Listing out all symbols seems not very smart to me.

.



Relevant Pages

  • Re: Package nicknaming at :use time or reader time
    ... If short names conflict one has:shadow and:shadow-import. ... I cannot find:nick in the clhs page for defmacro. ... was that the choice of nicks happens at package definition, ... 0xE9758B7D or 'Peter Schuller ' ...
    (comp.lang.lisp)
  • Re: same symbol name in 2 different packages
    ... When you USE a package, ... But one can still do all that in DEFPACKAGE, which supports:SHADOW ... the conflict, giving preference to the package being defined: ...
    (comp.lang.lisp)
  • Re: How to Easily Specify Export Symbol
    ... > I was developing my own little package shadowing some of LISP function ... reasonable way to do this would be to have your cl-oo package take the ... plus any defined in cl-oo (including the ones that shadow the cl base ...
    (comp.lang.lisp)
  • Re: Package nicknaming at :use time or reader time
    ... If short names conflict one has:shadow and:shadow-import. ... something, or did you mean:nicknames? ... was that the choice of nicks happens at package definition, ...
    (comp.lang.lisp)
  • Re: Difference between #(lambda ...) and (lambda ...) ?
    ... You mean the macro contains the package namespace in it's closure? ... All symbol objects in CL belong to a package. ... extend LAMBDA for some reason, you define your lambda in a new package ... and shadow CL:LAMBDA, i.e. the official lambda. ...
    (comp.lang.lisp)