[plt-scheme] A macro to signify Scheme

From: Mike T. Machenry (dskippy at ccs.neu.edu)
Date: Fri Apr 23 02:07:50 EDT 2004

I am try to write a module language which will not provide mzscheme but
instead a macro that will allow its body access to mzscheme. Currently
it looks something like this:

(define-syntax (scheme stx)
  (syntax-case stx ()
    [(_ expr)
     (with-syntax ([my-if (datum->syntax-object #'expr 'if)])
       #'(let-syntax ([my-if (lambda (stx)
                               (syntax-case stx ()
                                 [(_ test then else) #'(if test then else)]
                                 [(_ test then)      #'(if test then)]))])

This is macro that give its body IF and anything else that is properly added
to that let-syntax. The problem here is that I can't redefine all of mzscheme
this way. Is there a way to provide all of the mzscheme forms being care to
still cause the expressions to evaluate with the same lexical scope and
everything like that? Idealy I want

(module foo mylanguage
  (define (f n) (add1 n))
  (if (scheme (= (f 4) 5))

Note here that define, if, and something* are forms provided by my language
and the define form has an implicit (scheme expr ...) for the exprs in it's


Posted on the users mailing list.