|
Boost : |
From: Greg Colvin (greg_at_[hidden])
Date: 2000-07-25 11:25:01
From: Reid Sweatman <borderland_at_[hidden]>
> > But seriously, the trouble with template metaprogramming
> > is that the syntax was never designed for the purpose,
> > so it's just terrible to read and write. So while there
> > is no good reason to use macros to turn C++ into Pascal
> > when the C++ is perfectly readable, a set of macros that
> > let you write readable metaprograms might be quite useful,
> > if only the C preprocessor wasn't so brain-dead.
>
> Well, I hate to suggest anything that goes outside the C++ language spec and
> available tools, but there are plenty of other readily available things that
> make wizard preprocessors; you just have to invoke them in the make before
> the compiler. My favorite is PERL, but I've used AWK and rolled my own
> oddities for special purposes. And while I haven't looked at it yet, I
> understand Python would be as good a choice. I guess a second problem would
> be picking a standard <g>. At least, PERL's free on just about every
> platform. Anyway, I'm guessing the mere fact that it's not a native C++
> tool will kill any interest for the suggestion in this list. Still, thought
> I'd toss it out. I guess the real solution is to get a worthwhile
> preprocessor added to the language spec. Dunno what the odds are, though.
One of the goals for templates was to eliminate the need for the C
preprocessor. That goal was met for most traditional uses of CPP.
But one use of the C preprocessor has always been to create new
syntatic forms where coding in straight C was too difficult but
using another language to generate C was not a good option. For
example, we make heavy use of macros to code our Java object model
in C. As we push the limits of template metaprogramming we find
ourselves with a similar mismatch, which eventually will need to
be resolved with new syntax in C++, and/or new languages better
suited to the idiom.
------------------------------------------------------------------
Greg Colvin greg_at_[hidden] gcolvin_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk