Subject: Re: finding package name of a symbol at execution time
From: (Rob Warnock)
Date: Wed, 29 Aug 2007 03:08:17 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Pillsy  <> wrote:
| Frank Goenninger DG1SBG <> wrote:
| > I currently only get the current package I am *using* the symbol
| > in.
| You can get a list of all the packages it might be defined in, and
| then see which package (if any) it's actually defined in. First check
| to see if it's an :INTERNAL or :EXTERNAL symbol of *PACKAGE*, and then
| see if it's an :EXTERNAL symbol of any of the packages that *PACKAGE*
| uses. Like so:
| (defun find-package-defining-symbol (designator)
|   (let ((name (string designator)))
|     (labels ((in-package-p (package)
| 	      (nth-value 1 (find-symbol name package))))
|      (if (member (in-package-p *package*) '(:external :internal))
| 	 *package*
| 	 (find :external (package-use-list *package*) :key #'in-package-p)))))

More generally, don't forget about APROPOS-LIST.
Not applicable to the OP's problem, but can often
be useful in user-written debugging aids.


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607