[plt-scheme] how to debug expansions to top-level forms?

From: Felix Klock's PLT scheme proxy (pltscheme at pnkfx.org)
Date: Thu Jun 26 10:39:23 EDT 2003

PLT Scheme peeps-

Well, as I mentioned earlier, I'm trying to port MIT Scheme's emacs 
clone, Edwin, to PLT Scheme.  Inspired by a conversation with Matthias, 
I've decided to make the job interesting by doing the port in the form 
of a mit-scheme language module, and then just wrapping all of the 
Edwin source files with `(module ,file-name mit-scheme ,file-body) [so 
to quasispeak] ...

(I'm not really going to try to support all of MIT Scheme's features.  
 From reading some of the RRRS archive, I get the impression that Edwin 
avoids some of the more eclectic features, such as first class 
environments)

However, while I was working on a translation from MIT's 
define-structure form to PLT's define-struct form, I discovered an 
inability to use (expand ...) on the macro I was defining, even though 
the macro itself was able to successfully expand when applied in actual 
code.

I've reduced the problem down to a simple test case:

=== Definitions ===
(define-syntax bind-to-vals
   (lambda (stx)
     (syntax-case stx ()
       [(bind-to-vals EXPR NAME ...)
        (let ()
          (quasisyntax
           (define-values (NAME ...)
             EXPR)))])))

=== Interactions ===
Welcome to DrScheme, version 204.
Language: Pretty Big (includes MrEd and Advanced).
 > (bind-to-vals (values 1 2 3) x y z)
 > (list x y z)          #| see, it worked! |#
(1 2 3)
 > (expand (bind-to-vals (values 1 2 3) x y z))
define-values: illegal use (not at top-level) in: (define-values (x y 
z) (values 1 2 3))
 > #| you get the same response when using expand-once or 
expand-to-top-form |#

So, can someone tell me how I can use (expand ...) to debug macros like 
this?  I've been getting by so far by inserting display statements into 
the actual expansion procedures, but I'd like to use a more interactive 
debugging solution (to cut down on the redefine/execute/reinteract 
cycles)

Thanks,
-Felix



Posted on the users mailing list.