[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

help understanding defpackage

Jim Newton

4/11/2016 2:39:00 PM

Can someone help me understand the following defpackage usage.

(defpackage :dispatch
(:export)
(:use :cl :closer-mop)
(:shadow "STANDARD-GENERIC-FUNCTION"
"DEFMETHOD"
"DEFGENERIC"))

(in-package :dispatch)

I would like this to mean that when I use standard-generic-function, defmethod, and defgeneric
in the remainder of the file, I'd like it to refer to closer-mop::standard-generic-function etc,
rather than to cl::standard-generic-function etc.

Is there a way to construct my defpackage to mean what I want?

3 Answers

Jocelyn Fréchot

4/11/2016 4:30:00 PM

0

On 11/04/2016 16:38, Jim Newton wrote:

> (defpackage :dispatch
> (:export)
> (:use :cl :closer-mop)
> (:shadow "STANDARD-GENERIC-FUNCTION"
> "DEFMETHOD"
> "DEFGENERIC"))
>
> (in-package :dispatch)
>
> I would like this to mean that when I use standard-generic-function, defmethod, and defgeneric
> in the remainder of the file, I'd like it to refer to closer-mop::standard-generic-function etc,
> rather than to cl::standard-generic-function etc.

You need :SHADOWING-IMPORT-FROM instead of :SHADOW.

--
Jocelyn Fréchot

Jim Newton

4/12/2016 9:46:00 AM

0

Great. That seems to work fine.

(defpackage :dispatch
(:export)
(:use :cl :closer-mop)
(:shadowing-import-from :closer-mop
"STANDARD-GENERIC-FUNCTION"
"DEFMETHOD"
"DEFGENERIC"))

(in-package :dispatch)

Pascal Costanza

4/13/2016 7:57:00 AM

0

On 12/04/16 11:45, Jim Newton wrote:
> Great. That seems to work fine.
>
> (defpackage :dispatch
> (:export)
> (:use :cl :closer-mop)
> (:shadowing-import-from :closer-mop
> "STANDARD-GENERIC-FUNCTION"
> "DEFMETHOD"
> "DEFGENERIC"))
>
> (in-package :dispatch)
>

You can also just use the packages closer-common-lisp and
closer-common-lisp-user, which replace all the predefined CLOS-related
symbols in common-lisp with their redefinitions from closer-mop, if
necessary. The exact shadowing relationships can vary from CL
implementation to CL implementation, but the effect should always be
that you get "correct" CLOS MOP functionality.

Pascal

--
My website: http:/...
Common Lisp Document Repository: http://cdr.eu...
Closer to MOP & ContextL: http://common-lisp.net/proje...
The views expressed are my own, and not those of my employer.