Temporary package nicknames with ap-pkg

Discussion of Common Lisp

Temporary package nicknames with ap-pkg

Postby WeYu » Sat Oct 24, 2009 2:45 pm

Autoproject has added a module that supports temporary package renaming with (simple) conflict resolution. Should work on any implementation. Give it a go.

From the readme:

The function AUTOPROJECT.PKG:ALIAS provides a straightforward facility for renaming packages temporarily as if they were local to a system or package. Any nicknames except the standard package names can be chosen, as package name conflicts are handled by a 'shadowing' mechanism.

Example usage:

In packages.lisp:

Code: Select all
(defpackage :my-package
  (:use :cl)
  (:export #:my-function))
 
(pkg:alias '((:com.really.long.package.util :util)
                  (:com.another.package.foo :foo)
                  (:com.a.third.package.bar :bar)))


In code.lisp:

Code: Select all
(defun my-function (x)
   (let ((q (util:prepare-for-xuul x)))
     (foo:handle-xuul (bar:make-xuul q))))
 
 ;; Be nice to others, reset nicknames
 (pkg:alias)


WeYu
 
Posts: 9
Joined: Sun Aug 10, 2008 1:14 pm

Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 3 guests