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

By: Yannis Lilis, Anthony Savidis


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. Effectively, 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 suffer 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 offering 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 offering runtime metaprogramming.


Metaprograms; compile-time metaprogramming; run-time meta-programming; staged languages; source-level debugging; error messages.

Cite as:

Yannis Lilis, Anthony Savidis, “An Integrated Approach to Source Level Debugging and Compile Error Reporting in Metaprograms”, Journal of Object Technology, Volume 12, no. 3 (August 2013), pp. 1:1-26, doi:10.5381/jot.2013.12.3.a2.

PDF | DOI | BiBTeX | Tweet this | Post to CiteULike | Share on LinkedIn

The JOT Journal   |   ISSN 1660-1769   |   DOI 10.5381/jot   |   AITO   |   Open Access   |    Contact