It seems you need commas before your references of result.
Marc
On 2013-09-27, at 2:20 PM, Bradley Lucier lucier@math.purdue.edu wrote:
Marc:
I'm trying to write my own tracing routine for my new naive-div routine, and it's a little tricky.
I wrote the following macro to (1) use naive-div-new for naive-div, (2) collect the args and results of all calls to naive-div-new when computing an expression, (3) resetting naive-div to naive-div-orig, and (4) pretty-printing some of the results.
(define-macro (while-tracing-naive-div-new expression) (let ((result (gensym)) (args+result (gensym))) `(let ((,args+result '())) (set! naive-div (lambda (u v) (let ((result (naive-div-new u v))) (set! ,args+result (cons (list u v result) ,args+result)) result))) ;; calculate expression with naive-div-new (let ((result ,expression)) ;; set naive-div back to naive-div-orig before calling any more number-manipulating routines (set! naive-div naive-div-orig) (pp (map (lambda (args+result) (append args+result (list (naive-div-orig (car args+result) (cadr args+result))))) ,args+result)) ;; supposed to return result, but returns #!void ???????????????? result))))
I use it in the following way:
(while-tracing-naive-div-new (string->number (number->string
xx)))
which expression is expanded by
gsc -expansion -c test-naive-div.scm > ! crap.scm
to
(let ((#:g4 ('#<procedure #24 ##box> '()))) (let ((begin-temp.27 (set! naive-div (lambda (u v) (let ((result (naive-div-new u v))) (let ((begin-temp.24 ('#<procedure #31 ##set-box!> #:g4 ('#<procedure #5 cons> ('#<procedure #6 list> u v result) ('#<procedure #25 ##unbox> #:g4))))) result)))))) (let ((result ('#<procedure #28 string->number> ('#<procedure #29 number->string> xx)))) (let ((begin-temp.26 (set! naive-div naive-div-orig))) (let ((begin-temp.25 (pp ('#<procedure #32 map> (lambda (args+result) ('#<procedure #33 append> args+result ('#<procedure #6 list> (naive-div-orig ('#<procedure #9 car> args+result) ('#<procedure #34 cadr> args+result))))) ('#<procedure #25 ##unbox> #:g4))))) #!void)))))
So where did the #!void at the end come from?
Brad