Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 629 Bytes

README.md

File metadata and controls

27 lines (20 loc) · 629 Bytes

expand.carp

is a simple hygienic macroexpander in and for Carp.

It’s based on this talk by Matthew Flatt and implements the simple nano expander. I intend to keep working on it when motivation strikes.

(load "expand.carp")

(defdynamic prog
  (Expand.introduce ; adds all the core primitives
    (Expand.from-datum ; builds a syntax object
      '(let-syntax [add (fn [s] (quote-syntax '(+ 1 3)))]
        (add)))))

; expands the syntax object and converts it back to
; regular Carp
(Expand.to-datum (Expand.expand-all prog))
; => '(+ 1 3)

Have fun!