Hi -
In the quest of writing some debug print functions I am trying to find
out the package in which a given symbol (of a function) is defined
in...
I currently only get the current package I am *using* the symbol
in.
Code used so far:
(format *debug-io* "~&*** ~A [ PKG ~A, FN ~A ( ~A ) ]~&"
msg-class (package-name *package*) method method-desc)
Oh - just a thought: if I do this as a macro at compile and
load-time ... Let's see (hacking away in other Emacs buffer) -
Any ideas? Thx!
Frank
--
Frank Goenninger
frgo(at)mac(dot)com
"Don't ask me! I haven't been reading comp.lang.lisp long enough to
really know ..."
On Aug 28, 9:30 am, Frank Goenninger DG1SBG <·············@nomail.org>
wrote:
> In the quest of writing some debug print functions I am trying to find
> out the package in which a given symbol (of a function) is defined
> in...
> 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)))))
Cheers,
Pillsy
Pillsy <·········@gmail.com> writes:
> 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)))))
>
> Cheers,
> Pillsy
>
I love it! Another example of "a simple question asked - got answers
at light speed - learned a lot more than I hoped for." This is c.l.l
at its best!
Thanks!!!
Frank
Pillsy <·········@gmail.com> wrote:
+---------------
| Frank Goenninger DG1SBG <·············@nomail.org> 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
-----
Rob Warnock <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
From: Zach Beane
Subject: Re: finding package name of a symbol at execution time
Date:
Message-ID: <m3k5rfai96.fsf@unnamed.xach.com>
Frank Goenninger DG1SBG <·············@nomail.org> writes:
> In the quest of writing some debug print functions I am trying to find
> out the package in which a given symbol (of a function) is defined
> in...
Does SYMBOL-PACKAGE do what you need?
Zach
Zach Beane <····@xach.com> writes:
> Frank Goenninger DG1SBG <·············@nomail.org> writes:
>
>> In the quest of writing some debug print functions I am trying to find
>> out the package in which a given symbol (of a function) is defined
>> in...
>
> Does SYMBOL-PACKAGE do what you need?
>
> Zach
Yes, thanks!!
Frank