Expressing DSLs in Lisp is quite different from doing so in other languages. In general you can't express DSLs in other languages in any useful sense (only by writing an interpreter in that language or writing a compiler to that language). In Lisp, though, using macros you can modify the language you are using, adapting it it to the problem domain.
This is easy to do and certainly not trivial (in terms of usefulness). For example, you might need a language for validating the structure of documents. DTDs are one example of these. In Lisp you can implement a series of macros so that you can express DTDs directly in Lisp (I've done this), then the DTD executes as a Lisp program. You just write DTDs using parenthesis instead of the usual syntax.
Or, consider something like YACC. YACC is a DSL for writing parsers. You could write a parser directly in C, but it would be very tedious. YACC programs (or specs or whatever they're called) are not C programs, though they get translated into C. In Lisp you could just extend the language to implement the semantics of YACC. You wouldn't need a separate YACC program.
Lisp is different.
As Guy Steele said: If you give a programmer FORTRAN, he has FORTRAN. If you give a programmer Lisp, he has any language he wants. Turing completeness isn't really the issue. Lisp is really convenient for implementing useful DSLs.
|