Life, the Universe and Everything.
1 Introduction
<lue>
<scribble-macro-expansion>
<scribble-macro-expansion-example>
<expanded-code>
<test-foo>
2 Conclusion
<main-module>
<module-test>
<*>
7.0

Life, the Universe and Everything.

    1 Introduction

    2 Conclusion

1 Introduction

<lue> ::=

(define lue 42)

Here is a macro:

(define-for-syntax mymacro-tmp
  (syntax-rules () [(_ a b) (let ((b 1)) a)]))
(define-syntax (mymacro-stx stx) #`'#,(mymacro-tmp stx))
(define-syntax mymacro mymacro-tmp)

We can use it like this:

(mymacro (+ x 3) x)

Which expands to (requires Racket ≥ 6.4 and a bit of set-up boilerplate to have the output in scribble, see http://lists.racket-lang.org/users/archive/2014-December/065175.html):

'(let ((x 1)) (+ x 3))

The code above should show the expanded code, i.e:

(let ((x 1)) (+ x 3))

(check-equal? lue 42)

2 Conclusion

(module main typed/racket
  (require (for-syntax syntax/parse
                       racket/syntax))
 
 
  (provide lue)
 
  <lue>
  <scribble-macro-expansion>)

(module* test typed/racket
  (require (submod "..")
           typed/rackunit)
 
  <test-foo>)

<*> ::=
(begin
  <main-module>
 
  (require 'main)
  (provide (all-from-out 'main))
 
  <module-test>)