February 27, 2003
The Metacode Extension

Shortly before Alessandra was born, I started work on a C++ language extension that makes metaprogramming another first-class programming paradigm in C++.

The extension learns from experience in designing a programming language of my own (called Xroma). Xroma is a very orthogonal and relatively simple language that gives compile-time access to a structured representation of the program (in a reflective way). However, I had long ago concluded that C++ is “too heavy” for such an approach (although some have tried).

However, as I was reconsidering the problem, I found a relatively simple and implementable alternative. It got me excited enough that I decided to implement it in our (the Edison Design Group's) front end. In just two evenings I had an elegant implementation of some very basic building blocks: Things you cannot do using template metaprogramming (but nothing earth-shattering yet).

Meanwhile, I had committed to present something along these lines at the ACCU Spring Conference. It turns out they need some sort of document about it by March 1st. As a result, I've been writing down the core ideas of my new Metacode extension.

Now, all there is to do is to implement the harder parts...

Posted by Daveed at 07:08 PM | Comments (3) | TrackBack (0)

Very interesting :)

One project of compile-time metapprogramming i'm aware of is OpenC++ Version 2 and higher.

It has undergone some improvement at version 2.5, but i haven't read all the documents yet. There are already several years of experience behind the project.

Anyway, i'm considering to make a meta-programming language extension for D programming language (which brings both improvement and simplification to C++), or to make a Pascal descendant with meta-programming as GCC frontend or generating D source.

For information on D: www.digitalmars.com/d/


Posted by: Ilya Minkov on March 20, 2003 06:33 AM

Thanks for the feedback. I was aware of OpenC++ and MPC++. I've only read high-level papers about these (no hands-on experience), but they seemed too complex for widespread use.

The metacode extension ended up being a pretty simple extension with almost no new C++ concepts. (The implementation may not be all that simple, but the programming model is.)

Posted by: Daveed on March 20, 2003 10:44 AM

Something like lisp macros in C or C++ would be great.

I built a programmable preprocessor that allows generic code manipultation through directives in fortran90. The language used to transform the fortran has features for examining and constructing chunks of code. It's been used for a few years on a few hundred thousand lines of code I'm trying to extend it with data flow information.

It would be great to make it more elegant and work it into Fortran but the users don't want that.

Let me know if you want some info.

Posted by: Matt on June 6, 2003 04:01 PM
Post a comment

Email Address:



Remember info?