Blogs menu:

Blogs

You are not logged in! Please create an account and log in to blog.


Package renaming in Common Lisp

By admin (2010-12-17 23:01)

Suppose you want to run in the same Lisp image two slightly differents systems: mostly same packages names and same symbols in these packages. This happens easily if your two systems share a common ancestor. I encountered this problem to run both ucw_ajax for my demos companion web site and this web site (which uses now ucw-core).

Renaming all packages from one system to new names will do the trick. And, nice enough, Common Lisp provides all the tools to do this. The commands needed with my example of ucw-core used with ucw_ajax are below (after loading ucw-core):

(rename-package (find-package "IT.BESE.UCW.SYSTEM") "IT.BESE.UCW2.SYSTEM" '("UCW2.SYSTEM"))
(rename-package (find-package "IT.BESE.UCW.LOGGERS") "IT.BESE.UCW2.LOGGERS" '("UCW2-LOG"))
(rename-package (find-package "IT.BESE.UCW.CORE") "IT.BESE.UCW2.CORE" '("UCW2-CORE"))
(rename-package (find-package "IT.BESE.UCW.CORE.GENERATED") "IT.BESE.UCW2.CORE.GENERATED")
(rename-package (find-package "UCW-AJAX") "UCW2-AJAX")
(rename-package (find-package "UCW-USER") "UCW2-USER")
(rename-package (find-package "UCW-TAGS") "UCW2-TAGS" '("<UCW2"))
(rename-package (find-package "UCW-STANDARD") "UCW2-STANDARD" '("UCW2"))


This will rename all ucw-core package names and their nicknames. It has to be done before loading ucw_ajax. Is this the end of the story? No, as the asdf systems names are also largely the same between ucw-core and ucw_ajax. To solve this last problem, just run what follows, again before loading ucw_ajax:

(remhash "ucw-core" asdf::*defined-systems*)
(remhash "ucw.httpd" asdf::*defined-systems*)
(remhash "ucw.iolib" asdf::*defined-systems*)
(remhash "ucw.mod-lisp" asdf::*defined-systems*)
(remhash "ucw-core.test" asdf::*defined-systems*)
(remhash "ucw" asdf::*defined-systems*)
(remhash "ucw-ajax" asdf::*defined-systems*)
(remhash "ucw.examples" asdf::*defined-systems*)


Now, try to solve the same kind of problem with another language! A close example may be the namespace convention of Perl.

Permalink