[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

template metaprogramming paper




Here'a a paper that I came across recently (courtesy of the "Lambda the
Ultimate" weblog (http://lambda.weblogs.com)) that I think might be of some
interest to the people on this list:

http://www.research.microsoft.com/~simonpj/papers/meta-haskell/

The idea here is to take the basic concepts underlying lisp/scheme macros
and C++ templates and import them into Haskell, a lazy functional language
with strong static typing (http://www.haskell.org).  In order to do this,
the metaprogramming system has to be substantially more complex than lisp
macros; part of this is because constructed expressions have to be
type-safe.  The authors define extensions to haskell that represent haskell
parse trees in the haskell program itself at three different levels of
complexity), and give a brief tutorial on how to do interesting things with
the metaprogramming system.  I found the paper pretty heavy going, but then
I'm far from a haskell expert.  Nevertheless, I'm very encouraged that
people (other than lisp and C++ programmers) are starting to realize the
advantages of compile-time code generation, and are working to extend it to
more languages.  Much of this is due to the recent developments in template
metaprogramming in C++; in fact, one might say that C++ may legitimize
macros in the same way that java legitimized garbage collection (and XML
sort of legitimizes S-expressions?).  Hey, one day lisp might be considered
totally legitimate ;-)

Mike