Aspect oriented Everything?

David Abrahams dave at boost-consulting.com
Thu Aug 28 03:33:48 EDT 2003


hungjunglu at yahoo.com (Hung Jung Lu) writes:

> (2) Yet another approach is using code templates, a la
> meta-programming. There are more complicated examples, like the second
> example in my previous posting, where it's not easily solved by one
> single code block, nor one single MixIn, nor by function composition.
> In that case one can assemble the code by using a template, and make
> successive pattern substitutions depending on the properties of the
> particular instrument. Of course, this approach is a bit beyond the
> reach of Java/C++, and anyway the strongly-typed language people would
> protest because your code may not have been properly verified by the
> compiler.

Don't lump Java and C++ together, please!

I am currently writing a book about metaprogramming in C++, using
(ahem) templates.  I realize that you were referring to a more
abstract concept when you wrote "template", but it's still amusing
that the very C++ feature which implements your "template" is called
"template".  Well, maybe I need more sleep.  It's amusing to me
anyway.

Anyway, the compile-time computational power of C++ templates goes far
beyond simple templated code generation.  In fact they have been shown
to be Turing-complete
(http://osl.iu.edu/~tveldhui/papers/2003/turing.pdf).  And, as for
proper code verification, template metaprogramming doesn't compromise
type-safety.  

Regards,
-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Python-list mailing list