unuse-package
unuse-package Function
Syntax:
unuse-package packages-to-unuse &optional package → t
Arguments and Values:
packages-to-unuse—a designator for a list of package designators.
package—a package designator . The default is the current package.
Description:
unuse-package causes package to cease inheriting all the external symbols of packages-to-unuse; unuse-package undoes the effects of use-package. The packages-to-unuse are removed from the use list of package.
Any symbols that have been imported into package continue to be present in package.
Examples:
(in-package "COMMON-LISP-USER") → #<PACKAGE "COMMON-LISP-USER">
(export (intern "SHOES" (make-package ’temp)) ’temp) → T
(find-symbol "SHOES") → NIL, NIL
(use-package ’temp) → T
(find-symbol "SHOES") → SHOES, :INHERITED
(find (find-package ’temp) (package-use-list ’common-lisp-user)) → #<PACKAGE "TEMP"> (unuse-package ’temp) → T
(find-symbol "SHOES") → NIL, NIL
Side Effects:
The use list of package is modified.
Affected By:
Current state of the package system.
See Also:
use-package, package-use-list
Expanded Reference: unuse-package
Basic Usage: Removing Package Inheritance
unuse-package reverses the effect of use-package. The specified package is removed from the use list, and its external symbols are no longer inherited.
(defpackage "SOURCE-UU" (:use) (:export "DATA"))
(defpackage "TARGET-UU" (:use "SOURCE-UU"))
(find-symbol "DATA" "TARGET-UU")
;; => SOURCE-UU:DATA
;; => :INHERITED
(unuse-package "SOURCE-UU" "TARGET-UU")
;; => T
(find-symbol "DATA" "TARGET-UU")
;; => NIL
;; => NIL
The Use List is Updated
(defpackage "LIB-UU" (:use) (:export "FN"))
(defpackage "APP-UU" (:use "LIB-UU"))
(mapcar #'package-name (package-use-list "APP-UU"))
=> ("LIB-UU")
(unuse-package "LIB-UU" "APP-UU")
=> T
(package-use-list "APP-UU")
=> ()
Imported Symbols Remain After unuse-package
Symbols that were explicitly imported (not just inherited) remain present even after unuse-package.
(defpackage "PROVIDER-UU" (:use) (:export "ITEM"))
(make-package "RECEIVER-UU" :use '())
(use-package "PROVIDER-UU" "RECEIVER-UU")
;; Import makes it directly present
(import (find-symbol "ITEM" "PROVIDER-UU") "RECEIVER-UU")
(find-symbol "ITEM" "RECEIVER-UU")
;; => PROVIDER-UU:ITEM
;; => :INTERNAL
(unuse-package "PROVIDER-UU" "RECEIVER-UU")
;; => T
;; Still present because it was imported
(find-symbol "ITEM" "RECEIVER-UU")
;; => PROVIDER-UU:ITEM
;; => :INTERNAL
Unusing Multiple Packages
unuse-package accepts a list of packages.
(defpackage "X-UU" (:use) (:export "A"))
(defpackage "Y-UU" (:use) (:export "B"))
(defpackage "Z-UU" (:use "X-UU" "Y-UU"))
(unuse-package '("X-UU" "Y-UU") "Z-UU")
=> T
(package-use-list "Z-UU")
=> ()