Subject: Re: Lisp code that writes non-lisp code
From: (Rob Warnock)
Date: 8 Jan 2001 04:01:37 GMT
Newsgroups: comp.lang.lisp
Message-ID: <93be31$lkcsc$>
Jim White <> wrote:
| Aubrey Jaffer's Schlep is a nifty tool which generates C:

It is nifty, especially the way it preserves top-level comments and
the care with which it tries to output well-formatted C. As Aubrey said,

  "Most programmers I work with are not fluent in Scheme and they
  have to be able to understand my code contributions."

But... After trying to work with it for a while, I just couldn't get
comfortable with the Hungarian (or is it reverse-Hungarian?) he uses
for typing. [Schlep looks at the last few characters of identifiers
and maps them to a C type.]  I tried adding CL-style declaim/declare
to it, and *sort of* got it working, but ran out of steam.

[I also tried adding "defmacro", so I could do repetitive coding at a
higher level, as well as compile-time meta-coding, and was again only
partially successful.]

Still, it's well worth studying/using/hacking-on if it's anywhere near
"close enough" to what you need...


p.s. IMHO, Schlep is not so much "a" program as a particular *pattern*
for writing Scheme/Lisp->C translators. That is, it's very much a
"habitable" environment [in the Alexander/Gabriel sense]. One is
*expected* to hack on it here & there to fit the task at hand.
(And indeed, if you grab snapshots of it from Jaffer's site, you'll
see that it mutates from time to time as he adds little additional
pieces for this task or that.)

Other, different patterns for similar thing may be found, say, in
MzScheme's wrapper for a "libguile" implementation, in particular the
file "plt/src/mzscheme/guile/mkghsrc" in the MzScheme source distribution,
which is almost trivial compared to Schlep, but is "good enough" to build
several dozen wrapper procedures in C. It too is worth studying, if only
to see how simply such things can be done in restricted applications.

Rob Warnock, 31-2-510
SGI Network Engineering
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA