Paper on Fortran->Lisp.

Tim Pierce twpierce@mail.bsd.uchicago.edu
Thu, 8 May 1997 15:51:50 -0500 (CDT)


> Date: Thu, 8 May 1997 12:53:16 +0300
> From: "Harvey J. Stein" <abel@netvision.net.il>
> 
> I just found this reference to Fortran->Lisp translation.  It might be
> relevant to C->Lisp translation.  Anyone interested in the subject and
> near a library might want to take a look at it:
> 
>    Fortran to Lisp translation using f2cl (with D. M. K. Willcock),
>    Software-Practice and Experience 26, 1127-1139, 1996. 

Thanks for the reference.  The source code for this compiler,
according to the article, can be found at
ftphost.cs.waikato.ac.nz:/pub/lisp/f2cl.

Having skimmed the article, I think it's interesting to note that
while the authors cite legacy Fortran 77 code as a reason for
having a f77->lisp compiler, they do not seem to discuss
experiences actually translating and using much legacy code with
the finished compiler.  That's telling.  Moreover, they list
several features of F77 that are simply not implemented; whenever
the compiler encounters such a feature, it emits a "***NOT
IMPLEMENTED***" string into the output file and describes briefly
which unimplemented feature produced it.

Not knowing Fortran, I can't comment on whether these omissions
are crucial, but I think we can safely extrapolate some things
from it.  It's generally easy to write a simple compiler for a
useful subset of a language: 90% of the things you want to
implement are the easy ones (e.g. if, for, while, + and so on).
The last 10% is the kicker.  Doubtless any of us here could write
a small C->Lisp compiler covering, say, every program described in
Kernighan and Ritchie, Edition 1.  Writing a compiler that could
compile GCC, on the other hand, might not be so easy.

So I believe the question is whether such a C->Lisp compiler could
be useful for a significant amount of legacy code, if combined
with hand-translation of knottier C constructs.  hbaker's
experience here tells us something useful about Fortran->Lisp
translation in a production environment; knowing that C
programmers love to play fast and loose with the type system, and
cast complicated structures to bit-bags, should tell us something
useful about C->Lisp translation.

I imagine that a limited C->Lisp compiler would be just easy
enough to write and just functional enough (pardon the pun) to be
practical, even if the translation of larger C systems proves to
require more sweat.  But I don't think we could rely on a C->Lisp
compiler to do a lot of the work.

The compiler project would also need to cope with the loss of
libc, and either reimplement the bulk of these functions in Lisp,
or write the compiler to change `fopen' and `printf' functions to
`open-file' and `format'.  That may prove to be even more work
than the compiler proper.