2011/01/11

Common Lisp でパッケージのニックネームを変える

rename-package を使う。

(defun set-package-nicknames (package &rest nicknames)
(rename-package package (package-name package) nicknames))

(defpackage :foo
(:nicknames :bar))

(values (package-name :foo) (package-nicknames :foo))
;;=> "FOO"
;; ("BAR")

(set-package-nickname :foo :baz :baha)
;;=> #<PACKAGE "FOO">

(values (package-name :foo) (package-nicknames :foo))
;;=> "FOO"
;; ("BAHA" "BAZ")

(set-package-nickname :foo)
;;=> #<PACKAGE "FOO">

(values (package-name :foo) (package-nicknames :foo))
;;=> "FOO"
;; NIL

0 件のコメント: