Re: tracing all functions in a package
- From: "John Thingstad" <jpthing@xxxxxxxxx>
- Date: Sat, 30 Aug 2008 13:00:14 +0200
På Fri, 29 Aug 2008 22:35:48 +0200, skrev John Thingstad <jpthing@xxxxxxxxx>:
I wanted to trace all functions in a package and ended up with the unusually thorny code..
(loop for sym being each present-symbol in :pat-match if (fboundp sym) do (eval `(trace ,sym)))
Is there a better way to do this?
Thanks to all that replied. I eventually ended up with the following code.
(Just another utillity in my /Lisp Programs/misc directory.)
Note that 'package can be a a package structure, a package symbol or nick and defaults to current *package*.
use:
(load "../misc/traceall")
(tu:trace-all)
....
(tu:untrace-all)
code:
(defpackage :trace-utilleties
(:nicknames :tu)
(:use :cl)
(:export package-function-symbols trace-all untrace-all))
(in-package :trace-utilleties)
(defun package-function-symbols (&optional (package *package*))
"Return a list of all functions is a package.
A symbol is a function symbol if it is fboundp and not a macro or spesial operator."
(let (result
(current-package (if (packagep package) package (find-package package))))
(assert (not (eq current-package nil)) (package) "package ~S not found." package)
(do-symbols (symbol current-package result)
(when (and (eq (symbol-package symbol) current-package)
(fboundp symbol)
(not (macro-function symbol))
(not (special-operator-p symbol)))
(push symbol result)))
(nreverse result)))
(defmacro trace-all (&optional (package *package*))
"Trace all functions in package. Defaults to the current package."
`(trace ,@(package-function-symbols package)))
(defmacro untrace-all (&optional (package *package*))
"Untrace all the functins in the current package. Defaults to the current package."
`(untrace ,@(package-function-symbols package)))
--------------
John Thingstad
.
- Prev by Date: Re: What do you LISPers think of Haskell?
- Next by Date: Re: How much tuning does regular lisp compilers do?
- Previous by thread: Re: SBCL's (run-program ... :output out) is not working on Windows
- Next by thread: legitimate closure?
- Index(es):
Relevant Pages
|