Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Common Lisp Way to Rename a Namespace

Tags:

common-lisp

What is the common lisp way to rename a namespace to something else. So instead of writing hunchentoot:start I could write ht:start.

I'm looking for something like pythons import A as B.

Edit: Using the accepted answer, the code for adding a nickname for hunchentoot is as follows:

(rename-package :hunchentoot :hunchentoot '(:ht))
like image 741
tjb Avatar asked Oct 03 '12 14:10

tjb


2 Answers

What you call a namespace is a Common Lisp package created with defpackage

You would like the package nickname to be ht

Performing a defpackage on an existing package has implementation defined behavior, but some implementations permit adding nicknames that way.

There is also a function rename-package that renames and adds nicknames to a package.

like image 158
Doug Currie Avatar answered Oct 21 '22 01:10

Doug Currie


I use this :

(defpackage :foo+bar
  (:use :bar)
  (:export
   #:*foo* #:foo #:foo-p #:foo-ffs!
   . #.(let (ext)
         (do-external-symbols (sym :bar)
           (push (symbol-name sym) ext))
         ext)))
like image 31
thodg Avatar answered Oct 21 '22 03:10

thodg