Skip to content

Instantly share code, notes, and snippets.

@miyamuko
Created August 6, 2010 12:31
Show Gist options
  • Select an option

  • Save miyamuko/511247 to your computer and use it in GitHub Desktop.

Select an option

Save miyamuko/511247 to your computer and use it in GitHub Desktop.
「名前が衝突するためexportできません: hoge」を解消する
;; 「名前が衝突するためexportできません: hoge」を解消する
;; 衝突しているシンボルを unintern して回る
(defun find-conflict-symbols (sym)
(let ((name (symbol-name sym))
r)
(dolist (pkg (list-all-packages))
(multiple-value-bind (found table)
(find-symbol name pkg)
(when (and found (eql table :internal)
(not (equal sym found)))
(pushnew found r))))
(nreverse r)))
(defun unintern-conflict-symbols (sym)
(let (r)
(dolist (conflict (find-conflict-symbols sym))
(pushnew (format nil "~A::~A"
(package-name (symbol-package conflict))
(symbol-name conflict)) r)
(unintern conflict (symbol-package conflict)))
r))
#|
;; 実行例
(intern "hoge" :user)
hoge
nil
(intern "hoge" :win-user)
win-user::hoge
nil
(find-symbol "hoge" :user)
hoge
:internal
(find-symbol "hoge" :win-user)
win-user::hoge
:internal
(export '(win-user::hoge) :win-user)
t
(use-package :win-user :user)
名前が衝突するためuseできません: win-user:hoge
(find-conflict-symbols 'win-user::hoge)
(hoge)
(unintern-conflict-symbols 'win-user::hoge)
("user::hoge")
(use-package :win-user :user)
t
|#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment