[plt-scheme] Question about eval and environments

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Fri Oct 26 03:21:56 EDT 2007

I don't know if this helps: if you're prepared to permanently add  
(set! x ...) to your code you could do this:

   > (define debug-enabled?
       (make-parameter #t))

   > (define (debug-hook x)
       (if (debug-enabled?)
           (begin (display "DEBUG> ")
                  (let ([fn (eval (read))])
                    (fn x)))

   > (define (run-test)
       (define x 10)
       (set! x (debug-hook x))
       (display x)

   > (run-test)

   DEBUG> (lambda (x) (* x 10))

You could get rid of the set! with a macro, although it would still  
be there in reality of course.


-- Dave

Posted on the users mailing list.