Source-to-Source Compilation in Racket: You Want it in Which Language?

Tero Hasu
BLDL and University of Bergen

Matthew Flatt
PLT and University of Utah


Racket's macro system enables language extension and definition primarily for programs that are run on the Racket virtual machine, but macro facilities are also useful for implementing languages and compilers that target different platforms. Even when the core of a new language differs significantly from Racket's core, macros offer a maintainable approach to implementing a larger language by desugaring into the core. Users of the language gain the benefits of Racket's programming environment, its build management, and even its macro support (if macros are exposed to programmers of the new language), while Racket's syntax objects and submodules provide convenient mechanisms for recording and extracting program information for use by an external compiler. We illustrate this technique with Magnolisp, a programming language that runs within Racket for testing purposes, but that compiles to C++ (with no dependency on Racket) for deployment.


  author =       {Tero Hasu and Matthew Flatt},
  title =        {Source-to-Source Compilation in {Racket}:
                  You Want it in Which Language?},
  booktitle =    {Preproceedings of the 26nd Symposium on
                  Implementation and Application of Functional
                  Languages (IFL 2014)},
  year =         2014,
  month =        oct,
  location =     {Boston, Massachusetts}


(define hasu-flatt-14-source
     @elem{Source-to-Source Compilation in Racket:
           You Want it in @emph{Which} Language?}
   #:author (authors "Tero Hasu" "Matthew Flatt")
   #:date "2014"
   #:location (proceedings-location
     @elem{Intl. Sym. Implementation and Application of
           Functional Languages (Preproceedings)})))

Publication Details