[plt-scheme] Macro stepper gone wild

From: Ryan Culpepper (ryanc at ccs.neu.edu)
Date: Wed Oct 10 19:50:15 EDT 2007

On Thu, 2007-10-11 at 00:06 +0200, Majorinc, Kazimir wrote:
> This macro works fine but Macro stepper (371) behaves wildly and
> reports some internal errors.
> 
> (define-macro (!!! . args0)
> (cons 'begin
> (map (λ(p)
> `(define-macro
> ,(cons (string->symbol
> (string-append (symbol->string p) "!"))
> 'args)
> `(begin (set! ,(car args) ,
> (append (list (quote ,p)) args))
> ,(car args))))
> args0)))
> 
> (!!! or and + - sin max min string-append cons)
> 
> (define x 3)
> (+! x 1)
> (max! x 2)
> (max! x 5)
> -------
> output (as it should be):
> 4
> 4
> 5
> -------
> (!!! + - ...) defines macros +!, -! ... such that
> (+! x expr) expands in (set! x (+ x expr)) ...
> 
> What's going on? Is it my or PLT bug? I think it is at least partly
> PLT because whatever is wrong, it shouldn't be internal error.

It's the macro stepper's fault. I've just committed a fix to
SVN---thanks for the bug report.

If updating is a problem, you can work around the problem by spelling
out unquote in the mapped procedure, thus:

        (map (λ(p)
               `(define-macro
                  (unquote (cons (string->symbol ___

Explanation, for the curious:

The problem was that the macro stepper tries to display things like
(quote x) as 'x if you originally typed them as 'x (or quasiquote,
unquote, etc). When it abbreviates reader macros like that, it omits
information on the quote-like symbol. Since the pretty-printer doesn't
print the symbol at all, that's okay.

It turns out, however, that occasionally the pretty-printer decides to
print 'x as (quote x), such as after a definition form. In that case, it
asks for the extra information, which isn't available. Thus the errors.

Ryan

> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.