Repository logo
 

MacoCaml: Staging Composable and Compilable Macros

Published version
Peer-reviewed

Repository DOI


Type

Article

Change log

Abstract

jats:pWe introduce MacoCaml, a new design and implementation of compile-time code generation for the OCaml language. MacoCaml features a novel combination of macros with phase separation and quotation-based staging, where macros are considered as compile-time bindings, expression cross evaluation phases using staging annotations, and compile-time evaluation happens inside top-level splices. We provide a theoretical foundation for MacoCaml by formalizing a typed source calculus maco that supports interleaving typing and compile-time code generation, references with explicit compile-time heaps, and modules. We study various crucial properties including soundness and phase distinction. We have implemented MacoCaml in the OCaml compiler, and ported two substantial existing libraries to validate our implementation.</jats:p>

Description

Keywords

Staging, Macros, Compile-time code generation, OCaml

Journal Title

Proceedings of the ACM on Programming Languages

Conference Name

Journal ISSN

2475-1421
2475-1421

Volume Title

7

Publisher

Association for Computing Machinery (ACM)
Sponsorship
Engineering and Physical Sciences Research Council (EP/K031724/2)
European Commission Horizon 2020 (H2020) ERC (101002277)
Isaac Newton Trust (13.21(c)/18.47(a))