Ken Tilton <kentilton@gmail.com> wrote:
+---------------
| What is needed is an example of where an application
| code pattern can be automated, and natch it has to be
| one where a function would not do.
+---------------
One that immediately comes to mind for me is the MACRO-10
macros I used in implementing FOCAL-10 [about which I have
written too many times elsewhere], which collected dribbles
of data from the programmer [me] that was distributed
throughout the source code and planted a heavily-munged,
reformatted version of the accumulated data in a single table
at the end... AT COMPILE TIME. This is *very* convenient in
Lisp, whereas user of other languages tend to write various
external pre-processing (think "literate programming") hacks
in Perl or whatever that write out C source files, which then
get compiled/linked with or #include'd in the program.
The advantage of Lisp [or MACRO-10] macros is that the
data being accumulated can *also* be used *while* the
program text is being compiled to further conditionalize
the code being generated, something that's very hard to
do with the external pre-processing approach without having
to "generate" *all* of your program source code from a
meta-source.
[Re-implementing FOCAL in CL -- just to have an illustration
of the above -- is one of those elusive "round tuit" thingies
I haven't gotten yet. (*sigh*)]
Another good example [well, for me it is, though few non-Lispers
might appreciate it] is the definition & use of the VOP, VOP*,
DEFINE-VOP, DEFINE-MOVE-VOP defining macros [and friends] in
the CMUCL compiler. They provide a domain-specific language for
describing virtual instruction sets. From a comment in the source:
;;;; VOP definition structures:
;;;
;;; Define-VOP uses some fairly complex data structures at meta-compile
;;; time, both to hold the results of parsing the elaborate syntax and
;;; to retain the information so that it can be inherited by other VOPs.
;;; The VOP-Parse structure holds everything we need to know about a VOP
;;; at meta-compile time.
;;;
CMUCL thus has its own little [or *not* so little!] compiler-compiler
inside itself.
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607