[plt-scheme] running an MzScheme debugger in Emacs?

From: Benjamin L. Russell (dekudekuplex at yahoo.com)
Date: Thu Apr 24 05:06:26 EDT 2008

Is there a way to run an MzScheme debugger in Emacs, similarly to the MIT Scheme debugger in Edwin?

According to the Section 3 of the text (see http://mitpress.mit.edu/sicp/psets/ps1/ps1_1.ps) for the "Introductory assignment" (http://mitpress.mit.edu/sicp/psets/ps1/readme.html) of the Sample Programming Assignments (http://mitpress.mit.edu/sicp/psets/index.html) for SICP, it is possible to invoke a debugger by typing 'D' into the MIT Scheme REPL in Edwin upon a syntax error.

However, there doesn't seem to be a way to do this in MzScheme in Emacs.  I would prefer to run MzScheme instead of MIT Scheme in Emacs for the exercises in this book.

Does anybody know how to invoke a debugger for MzScheme in Emacs upon occurrence of an error?

For example, suppose the following three procedures are defined as follows (see p. 5 of the aforementioned document):

(define p1
  (lambda (x y)
    (+ (p2 x y)
       (p3 x y))))

(define p2
  (lambda (z w)
    (* z w)))

(define p3
  (lambda (a b)
    (+ (p2 a)
       (p2 b))))

Then, in Edwin (or Emacs), evaluate the expression (p1 1 2) (say, by entering the text in a buffer, and then typing C-x C-e (where 'C' denotes the Ctrl key being held down)).

In MIT Scheme, this reportedly returns the following error message:

;The procedure #[compound-procedureP2] has been called with 1 argument
;it requires exactly 2 arguments.
;Type D to debug error, Q to quit back to REP loop:

Here, typing 'D' invokes the debugger.

Is there a way to do this similarly for MzScheme in Emacs?

Benjamin L. Russell

Posted on the users mailing list.