Automatically resolving a symbol naming conflict using asdf and defpackage
-
14-07-2021 - |
Question
I have defined a common lisp package using asdf which uses both parenscript and clsql.
But these packages have a naming conflict around the function GET-TIME. When the module is loaded I can resolve the conflict manually at the prompt (code may not be exact):
Select a symbol to be made accessible in package MY_PACKAGE:
1. PS-JS-SYMBOLS:GET-TIME
2. CLSQL-SYS:GET-TIME
I pick option 1.
What is the best way to modify my project so that this conflict is resolved automatically?
Do I modify the .asd file or the project.lisp file?
I think the answer might have something to do with :shadowing-import-from, but I don't really understand the examples given on that documentation page.
Solution 2
Based on @Rainer Joswigs answer above, the specific answer to my question was to write my defpackage form as follows:
(defpackage #:my-package
(:use :cl :clsql :parenscript)
(:shadowing-import-from :parenscript "GET-TIME")
)
OTHER TIPS
Packages, symbols, exporting, using, etc. are a feature of Common Lisp, and not ASDF specific.
CL-USER 1 > (defpackage "FOO" (:use "CL") (:export "BAZ"))
#<The FOO package, 0/16 internal, 1/16 external>
CL-USER 2 > (in-package "FOO")
#<The FOO package, 0/16 internal, 1/16 external>
FOO 3 > (defun baz () 'FOO)
BAZ
FOO 4 > (defpackage "BAR" (:use "CL") (:export "BAZ"))
#<The BAR package, 0/16 internal, 1/16 external>
FOO 5 > (defun bar:baz () 'bar::bar)
BAR:BAZ
FOO 6 > (in-package "CL-USER")
#<The COMMON-LISP-USER package, 54/64 internal, 0/4 external>
CL-USER 7 > (defpackage "ZIPPY"
(:use "FOO" "BAR")
(:shadowing-import-from "BAR" "BAZ"))
#<The ZIPPY package, 1/16 internal, 0/16 external>
CL-USER 8 > (in-package "ZIPPY")
#<The ZIPPY package, 1/16 internal, 0/16 external>
ZIPPY 9 > (baz)
BAR::BAR