Re: simple debugging utility

2009-03-24 Thread Meikel Brandmeyer
Hi, Am 24.03.2009 um 16:00 schrieb Mark Volkmann: Thanks! It looks like I don't need the let now. But there are reasons to keep it! Eg. returning the expression result! (defmacro dump [expr] `(let [value# ~expr] (println (pr-str (quote ~expr)) "=" (pr-str value#)) value#)) The

Re: simple debugging utility

2009-03-24 Thread Tom Faulhaber
For reference, here's a version I wrote while I was working on cl- format and the pretty printer: (defn prerr [& args] "Println to *err*" (binding [*out* *err*] (apply println args))) (defmacro prlabel [prefix arg & more-args] "Print args to *err* in name = value format" (cons 'prerr

Re: simple debugging utility

2009-03-24 Thread Joshua Fox
Eric Rochester has a debug macro, together with a walkthrough of how he built it, here http://writingcoding.blogspot.com/2008/09/stemming-part-19-debugging.html Joshua On Tue, Mar 24, 2009 at 4:43 PM, Mark Volkmann wrote: > > I want to write a function or macro that allows me to output the value

Re: simple debugging utility

2009-03-24 Thread Konrad Hinsen
On Mar 24, 2009, at 16:00, Mark Volkmann wrote: > Thanks! It looks like I don't need the let now. Indeed. > Does a macro have to evaluate to one form? For example, this works, > but it seems I can't > drop the do. Yes, a macro has to evaluate to one form. This is actually not so much a con

Re: simple debugging utility

2009-03-24 Thread Lauri Pesonen
2009/3/24 Mark Volkmann : > > Thanks! It looks like I don't need the let now. Does a macro have to > evaluate to one form? For example, this works, but it seems I can't > drop the do. > > (defmacro dump [expr] >  `(do >     (print (quote ~expr)) >     (println " =" ~expr))) How about: (defmacro

Re: simple debugging utility

2009-03-24 Thread Mark Volkmann
On Tue, Mar 24, 2009 at 9:55 AM, Konrad Hinsen wrote: > > On Mar 24, 2009, at 15:44, Mark Volkmann wrote: > >> I'm wondering if there is a way to avoid that using a macro. The hard >> part is printing the expression. The following doesn't work. It >> outputs "3 = 3". >> >> (defmacro dump2 [expr]

Re: simple debugging utility

2009-03-24 Thread Konrad Hinsen
On Mar 24, 2009, at 15:44, Mark Volkmann wrote: > I'm wondering if there is a way to avoid that using a macro. The hard > part is printing the expression. The following doesn't work. It > outputs "3 = 3". > > (defmacro dump2 [expr] > `(let [value# ~expr] > (pr ~expr) > (println " =" v

simple debugging utility

2009-03-24 Thread Mark Volkmann
I want to write a function or macro that allows me to output the value of an expression without repeating it. For example, I want something like (dump (+ 1 2)) to output "(+ 1 2) = 3". This works. (defn dump1 [string] (println string "=" (load-string string))) (dump1 "(+ 1 2)") Note how I had

simple debugging utility

2009-03-24 Thread Mark Volkmann
I want to write a function or macro that allows me to output the value of an expression without repeating it. For example, I want something like (dump (+ 1 2)) to output "(+ 1 2) = 3". This works. (defn dump1 [string] (println string "=" (load-string string))) (dump1 "(+ 1 2)") Note how I had