Skip to content

Instantly share code, notes, and snippets.

@llibra
Created August 7, 2011 04:29
Show Gist options
  • Save llibra/1130049 to your computer and use it in GitHub Desktop.
Save llibra/1130049 to your computer and use it in GitHub Desktop.
define package alias
;; 元のパッケージに新しいニックネームを付ける
(defmacro define-package-alias (name package-designator)
(let ((designator (gensym)))
`(let ((,designator ,package-designator))
(rename-package ,designator
,designator
(union (list (string ,name))
(package-nicknames ,designator)
:test #'equal)))))
(define-package-alias :r :cl-ppcre)
;; 元のパッケージを継承して必要なシンボルだけエクスポートする
(defmacro define-synonym-package (name package-designator)
(let ((desinator (gensym))
(new-package (gensym))
(symbol (gensym)))
`(let* ((,desinator ,package-designator)
(,new-package (make-package ,name :use ,desinator)))
(let ((*package* ,new-package))
(do-external-symbols (,symbol (find-package ,desinator))
(export ,symbol)))
,new-package)))
(define-synonym-package :r :cl-ppcre)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment