Re: A simple debugging macro
- From: Ken Tilton <kennytilton@xxxxxxxxxxxxx>
- Date: Fri, 30 Nov 2007 11:34:08 -0500
fairchild.anthony@xxxxxxxxx wrote:
Here's a macroexpand:
CL-USER> (pprint (macroexpand-1 '(print-vars "before" a b c "after")))
(PROGN
(WRITE-STRING "TRACE: " *TRACE-OUTPUT*)
(PROGN (WRITE-STRING "before") (WRITE-STRING " "))
(FORMAT *TRACE-OUTPUT* "~A=~S " 'A A)
(FORMAT *TRACE-OUTPUT* "~A=~S " 'B B)
(FORMAT *TRACE-OUTPUT* "~A=~S " 'C C)
(PROGN (WRITE-STRING "after") (WRITE-STRING " "))
(TERPRI *TRACE-OUTPUT*)
(FINISH-OUTPUT *TRACE-OUTPUT*))
; No value
Which reminds me, you probably want the expnasion to be:
(call-print-vars "before" a b c "after")
....and with mine, if the first arg is a hard-coded nil (not a form which might evaluate to nil at runtime, which would mean "do not emit this time") the expansion is:
(progn)
Makes it quick and easy to disable/re-enable debug stuff I suspect will be needed again.
Thanks again! Now I'm off to look at kenny's suggestions.
If you like them you might want to start from the stuff in utils-kt. Less often needed but great when needed is a with-trc macro that wraps a possibly recursively invoked form such that output is indented to reflect recursion depth.
Another favorite of mine is
(with-metrics <counts?> <timing?> <insert usual trc args> &body)
timing being t causes the form to be wrapped in (time ), counts being t invokes a counting utility, initializing it, running the body, and then dumping the count results. counting is easy:
(count-it :hi-mom)
or
(count-it :color-change this-color)
the latter giving you a histogram by color value.
kt
--
http://www.theoryyalgebra.com/
"In the morning, hear the Way;
in the evening, die content!"
-- Confucius
.
- Follow-Ups:
- Re: A simple debugging macro
- From: fairchild.anthony@xxxxxxxxx
- Re: A simple debugging macro
- References:
- A simple debugging macro
- From: fairchild.anthony@xxxxxxxxx
- Re: A simple debugging macro
- From: Rainer Joswig
- Re: A simple debugging macro
- From: fairchild.anthony@xxxxxxxxx
- Re: A simple debugging macro
- From: fairchild.anthony@xxxxxxxxx
- A simple debugging macro
- Prev by Date: Re: The origins of CL conditions system
- Next by Date: Re: Why doesn't (open ... :if-exists) support :truncate?
- Previous by thread: Re: A simple debugging macro
- Next by thread: Re: A simple debugging macro
- Index(es):