From: Leo Sarasua
Subject: Lisp source translator to C
Date: 
Message-ID: <4tcfiq$1a5@nosy.bart.nl>
I need a program to translate some LISP source code into C/C++ or Pascal. 
Before I reinvent the wheel and waste a lot of effort into this sort of 
compiler, does anyone know if that exists somewhere? If not, is there 
anyone interested in helping with it?
Thanks a lot.
Leo Sarasua
From: Howard R. Stearns
Subject: Re: Lisp source translator to C
Date: 
Message-ID: <31FCCCC4.3F54BC7E@elwoodcorp.com>
Leo Sarasua wrote:
> 
> I need a program to translate some LISP source code into C/C++ or Pascal.
> Before I reinvent the wheel and waste a lot of effort into this sort of
> compiler, does anyone know if that exists somewhere? If not, is there
> anyone interested in helping with it?
> Thanks a lot.
> Leo Sarasua

There are several options, including one provided by my employer (Eclipse,
item 5):

1. Public domain Lisps which hack C.  GCL, ECoLisp, and other KCL derivatives
work by compiling Lisp to C and then using a standard C compiler.  However,
the resulting C code is not readable.  I believe the systems are intended as
traditional Lisp Top-Level systems, in which everything runs from within Lisp
-- not as a mechanism for producing C files which can be compiled and linked
in traditional C style to produce stand-alone executables.  Despite these
difficulties, I believe these systems have been used this way, especially
ECoLIsp.  

Also, various Scheme implementations compile to C, though rarely producing
readable C code, and often employing manipulations of the C stack which may
make the translated Lisp a bad citizen in the C world.

 GCL  ftp://prep.ai.mit.edu/pub/gnu   

 ECL http://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/impl/ecolisp/0.html

2. CLiCC is a Common Lisp to C translator project at the University of Kiel.
It operates on a strict SUBSET of Common Lisp.  It is free, but usually runs
from within a commercial host Lisp.

ftp://ftp.informatik.uni-kiel.de/pub/kiel/apply/clicc-0.6.4.tar.gz

3. Chestnut Software used to provide a complete translation system, but was
very expensive, and Chestnut is now out of business.  

4. ILOG has a system which provides intermixing and translation between their
proprietary Lisp dialect and C++.  

 http://www.ilog.com

5. Eclipse is a very inexpensive new system which provides translation of
100% of the ANSI spec to human readable C.  There is a one-to-one
correspondense between Lisp variables/functions and C variables/functions.
The C function calling mechanism is used.  Lisp data may be held directly in
global or local C variables.

 http://www.elwoodcorp.com/eclipse.htm

Some things to think about:

  1. Why are you translating to C?  Is it simply to satisfy an external,
political requirement?

  2. What dialect of Lisp are you using?  How much code are you willing to
rewrite?

  3. Who will see the translated code?  Only a C compiler, or will people be
exptected to read and even maintain the C code?  How does the translator
handle such issues as:
  - the Lisp package system
  - the fact that Common Lisp uses different namespaces for functions,
variables, go tags, blocks, etc., but C uses only one.

  4. What interoperability requirements are there between Lisp and C?  Must C
functions be able to call Lisp functions?  (Some systems use non-standard
calling conventions for Lisp functions.)  Must C functions be able to hold
Lisp data?  (The relocating garbage collector used by some system makes this
difficult, though usually still possible).  Must the garbage collector keep
track of Lisp data on the C stack or in C variables?  How does the translator
handle closures?

  5. Do you have control over the entire application or is there a main()
which is controlled elsewhere?  (Some systems require Lisp to be the main
controlling program.)

  6.  What are your delivery requirements?  Some systems may only be
deliverable as a single monolithic executable, others as shared libraries,
etc.  What platforms will the system ultimately be compiled on?  Does the tr
anslator require a runtime license?

  7. Are there particular requirements on the kind of C code to be produced?
K&R, ANSI, C++?  Does the translation use features that lock you in to a
particular C compiler (eg. GCC features, or C++ quirks)?