Metacza Compiles to C++ Template Meta Language


Synopsis

The Template Meta Compiler with Zero Apprehension

Metacza compiles a functional language to C++ Template Meta Language. It can be used to ease Template Meta Programming in C++.

The C++ Template Meta Language (C++-TML) is surprisingly powerful. It is actually a higher order purely functional language with multiple dispatch. All these features are supported by Metacza. Metacza also contains features for seamless integration into C++ projects, with or without the Boost.MPL library. Metacza allows the use of different namespaces and passes through pre-processor directives unchanged so that header files for C++ can be generated directly.

One of Metacza's design goals is to have only a shallow layer on top of C++ for two reasons:

  1. to have a seamless integration, i.e., the generated code should be usable from C++ when manually using C++ templates, and
  2. in order to keep the compiler small and simple so that it can easily understood what is going on.

Metacza is simple enough to only look at single statements, and the goal is to never need a native include mechanism so that each file can be translated individually. The difficult work is passed on to the C++ compiler.

Metacza documentation: [ introduction | syntax | examples ]


Example

Input: Metacza Output: C++
fib(n) = fib(n-1) + fib(n-2);
fib(0) = 0;
fib(1) = 1;
template<typename n>
struct fib {
  typedef
    typename plus<
      typename fib<
        typename minus< n, int_<1> >::type
      >::type,
      typename fib<
        typename minus< n, int_<2> >::type
      >::type
    >::type
  type;
};

template<>
struct fib< int_<0> > {
  typedef int_<0> type;
};

template<>
struct fib< int_<1> > {
  typedef int_<1> type;
};

Note that this example is slightly simplified. If you want to try it out, use this example.


Bugs


Changes


Download Metacza

Source Code

metacza-4-src.tgz
metacza-4-src.tgz.md5


License

Metacza is distributed under the GNU General Public License, Version 3.

Content

Index

December 9th, 2011
Comments? Suggestions? Corrections? You can drop me a line.
zpentrabvagiktu@theiling.de
Schwerpunktpraxis
Datenschutz