Metaprogramming Languages
Introduction to Metaprogramming Languages
A metaprogram is a program that manipulates other programs (or itself) as its data. The canonical example is a compiler.
The basic problem is that any general-purpose programming language without a metaprogramming model that is designed to be as pleasant and expressive as the language itself will eventually frustrate the user with it's limitations. No-one can design the perfect language, and yet allowing users to extend the language in generic ways is avoided with a BondageAndDiscipline mentality
Examples of metaprograms are
- the compiler or interpreter of your favourite language
- Lex and Yacc
- CORBA's IDL compiler
- a Quine
- Programs to generate EJB code and XML from database metadata
- Using an {"Eval"} function in dynamic languages to execute a generated string as programming code