An Integrated Approach to Source Level Debugging and Compile Error Reporting in Metaprograms

Metaprogramming is an advanced language feature enabling to mix programs with definitions that may be executed either at compile- time or at runtime to generate source code to be put in their place. Such definitions are called metaprograms and their actual evaluation constitutes a compilation stage. As metaprograms are also programs, programmers should be supported in handling compile-time and runtime errors, something introducing challenges to the entire tool chain along two lines. Firstly, the source point of a compile error may well be the outcome of a series of compilation stages, thus never appearing within the original program. Eectively, the latter requires a compiler to track down the error chain across all involved stages so as to provide a meaningful, descriptive and precise error report. Secondly, every compilation stage is instantiated by the execution of the respective staged program. Thus, typical full-fledged source-level debugging for any particular stage should be facilitated during the compilation process. Existing implementations suer in both terms, overall providing poor error messages, while lacking the required support for debugging metaprograms of any staging depth. In this paper, we outline the implementation of a compile-time metaprogramming system oering all aforementioned facilities. Then, we detail the required amendments to the compilation process and the necessary interaction between the compiler and the tool-chain (IDE). Finally, we discuss how similar functionality could be achieved in systems oering runtime metaprogramming.

[1]  Zoltán Porkoláb,et al.  Debugging C++ template metaprograms , 2006, GPCE '06.

[2]  Jonathan Bachrach,et al.  D-Expressions : Lisp Power , Dylan Style , 1999 .

[3]  Bjarne Stroustrup,et al.  The C++ Programming Language: Special Edition , 2000 .

[4]  Tim Sheard Using MetaML: A Staged Programming Language , 1998, Advanced Functional Programming.

[5]  Laurence Tratt,et al.  Domain specific language implementation via compile-time meta-programming , 2008, TOPL.

[6]  Laurence Tratt,et al.  Compile-time meta-programming in a dynamically typed OO language , 2005, DLS '05.

[7]  Todd L. Veldhuizen,et al.  Using C++ template metaprograms , 1996 .

[8]  Walid Taha,et al.  A Bytecode-Compiled, Type-safe, Multi-Stage Language , 2001 .

[9]  Walid Taha,et al.  Mint: Java multi-stage programming using weak separability , 2010, PLDI '10.

[10]  Anthony Savidis,et al.  Supporting Compile-Time Debugging and Precise Error Reporting in Meta-programs , 2012, TOOLS.

[11]  Tim Sheard,et al.  Accomplishments and Research Challenges in Meta-programming , 2001, SAIG.

[12]  Paul Roe,et al.  Metaphor: A Multi-stage, Object-Oriented Programming Language , 2004, GPCE.

[13]  Dianne E Tuinenburg The C++ Programming Language: Special Edition , 2014 .

[14]  Alan Bawden,et al.  Quasiquotation in Lisp , 1999, PEPM.

[15]  Laurence Tratt,et al.  Domain Specific Language Implementation via Compile-Time MetaProgramming , 2008 .

[16]  David Abrahams,et al.  C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond (C++ In-Depth Series) , 2004 .

[17]  Krzysztof Czarnecki,et al.  DSL Implementation in MetaOCaml, Template Haskell, and C++ , 2003, Domain-Specific Program Generation.

[18]  Ken Arnold,et al.  The Java Programming Language , 1996 .

[19]  Ken Arnold,et al.  Java(TM) Programming Language, The (4th Edition) , 2005 .

[20]  Kenneth J. Turner Exploiting the m4 Macro Language , 1994 .

[21]  Simon L. Peyton Jones,et al.  Template meta-programming for Haskell , 2002, Haskell '02.

[22]  Anthony Savidis Dynamic Imperative Languages for Runtime Extensible Semantics and Polymorphic Meta-Programming , 2005, RISE.

[23]  Walter Bright,et al.  The D Programming Language , 2010 .

[24]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[25]  Walid Taha,et al.  MetaML and multi-stage programming with explicit annotations , 2000, Theor. Comput. Sci..