I’d like to use the Racket macro expander to translate programs from a given source language to a target language (both scheme-ish).
However, the expansion that `raco expand` does is too violent for my purposes---I would need a way to specify macro hiding (as in the macro stepper), in order to control the level of abstraction of the expanded code. Is that possible?
(module test play
(#%module-begin
(module configure-runtime '#%kernel
(#%module-begin (#%require racket/runtime-config) (#%app configure '#f)))
(#%provide b swap a)
(define-syntaxes
(swap)
(lambda (user-stx)
(let-values (((arg) user-stx))
(let-values (((rslt)
(#%app
(lambda (e)
(if (#%app stx-pair? e)
(if (#%app (lambda (e) null) (#%app stx-car e))
(#%app
(lambda (e)
(if (#%app stx-pair? e)
(#%app
cons/#f
(#%app stx-car e)
(#%app
(lambda (e)
(if (#%app stx-pair? e)
(let-values (((mh) (#%app stx-car e)))
(if mh
(if (#%app
stx-null/#f
(#%app stx-cdr e))
mh
'#f)
'#f))
'#f))
(#%app stx-cdr e)))
'#f))
(#%app stx-cdr e))
'#f)
'#f))
arg)))
(if rslt
(let-values (((sc1) (#%app unsafe-car rslt))
((sc2) (#%app unsafe-cdr rslt)))
(let-values ()
(#%app
syntax-protect
(let-values (((loc) (#%app check-loc 'syntax/loc user-stx)))
(#%app
t-subst
loc
(quote-syntax (let _ (set! _ _) (set! _ tmp)))
'(1 recur 2 recur 3)
(#%app
t-resyntax
'#f
(quote-syntax STX)
(#%app
t-list
(#%app t-subst '#f (quote-syntax (tmp _)) '(1) sc1)))
(#%app list '(1 2) sc1 sc2)
(#%app list '(1) sc2))))))
(let-values (((rslt) (#%app (lambda (e) null) arg)))
(if rslt
(let-values ()
(let-values () (#%app pattern-failure user-stx '(x y))))
(#%app raise-syntax-error '#f '"bad syntax" arg))))))))
(define-values (a) '10)
(define-values (b) '20)
(#%app
call-with-values
(lambda () (let-values (((tmp) a)) (set! a b) (set! b tmp)))
print-values)))