chickadee » aima » make-debug-environment

(make-debug-environment object make-printable-object) → environmentsyntax

Make an environment that prints debugging information (according to `debug?').

object
The object to debug
make-printable-object
A function which optionally transforms the object before printing
(define-syntax
  make-debug-environment
  (er-macro-transformer
    (lambda (expression rename compare)
      (let ((%print (rename 'debug-print)))
        (match expression
               ((_ object) `(lambda () (,%print ',object ,object)))
               ((_ object make-printable-object)
                `(lambda ()
                   (,%print ',object (,make-printable-object ,object)))))))))