Type Safe Reflective Metaprogramming

240
Следующее
Популярные
Опубликовано 6 сентября 2016, 18:02
The template facility of C++, through some serendipity, provides powerful support for metaprogramming and compile-time reflection. However, C++ also has many shortcomings, making C++ template metaprograms inefficient and difficult to maintain. Garcia introduces a calculus for reflective metaprogramming in his thesis that provides all of the power and flexibility of C++ templates and solves many of its problems. However, one of the problems that remains is that the residual program is not type checked until after meta computation is complete. Ideally, one would like the type system of the metaprogram to also guarantee that the residual program will type check, as is the case in MetaML. However, reflective metaprogramming includes computation over types, making the MetaML guarantee difficult to achieve. In this talk we discuss two approaches to dealing with this problem. The first approach catches type errors as early as possible by incrementally type checking code fragments as they are created and spliced together during meta computation. The second and more ambitious approach represents residual programs as generalized algebraic datatypes and relies on the type system of the metaprogramming language to guarantee that residual program is well typed.
автотехномузыкадетское