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.
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.
>
Marco Antoniotti เขียน:
> 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
>
>
This one seems like the nice way to do it. (Actually I have already
write a similar function but the function there seems more complete).
This will be one more site I have to keep in my bookmark. (Lots of that
library ought to be available as common-lisp.net project. It will make
life more pleasant).
"joesb" <··········@gmail.com> writes:
> 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.
To the extent this makes sense, I think what you really want is to
make your "cl-oo" package _be_ the core package for your system. A
reasonable way to do this would be to have your cl-oo package take the
set of all external common-lisp symbols and subtract from that set the
symbols you are going to shadow and then export that difference set
plus any defined in cl-oo (including the ones that shadow the cl base
ones) that you want public.
To that end see do-external-symbols:
http://www.lispworks.com/documentation/HyperSpec/Body/m_do_sym.htm
At that point all you need to do is:
(defpackage :my-app
(:use :cl-oo)
...)
/Jon
--
'j' - a n t h o n y at romeo/charley/november com
"joesb" <··········@gmail.com> writes:
> 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,
Then you need to export more:
(in-package :cl-oo)
(do-external-symbols (sym :common-lisp)
(export (find-symbol (symbol-name sym) :cl-oo)))
;; no need to (:export ...) in defpacakge :cl-oo
;; (unless you have non CL symbols to export too).
> I thought I would do
>
> (defpackage :my-app
> (:use :common-lisp :cl-oo))
No, you're not working with COMMON-LISP anymore, you're working with CL-OO:
(defpackage :my-app
(:use :cl-oo))
--
__Pascal Bourguignon__ http://www.informatimago.com/
The rule for today:
Touch my tail, I shred your hand.
New rule tomorrow.