Related articles |
---|
Designing a calling convention for a Lisp->C compiler msimoni@gmail.com (Manuel) (2010-06-03) |
Re: Designing a calling convention for a Lisp->C compiler marc@lithia.nl (Marc van Lieshout) (2010-06-03) |
Re: Designing a calling convention for a Lisp->C compiler kym@sdf.lonestar.org (russell kym horsell) (2010-06-04) |
Re: Designing a calling convention for a Lisp->C compiler kym@sdf.lonestar.org (russell kym horsell) (2010-06-06) |
Re: Designing a calling convention for a Lisp->C compiler cr88192@hotmail.com (BGB / cr88192) (2010-06-06) |
Re: Designing a calling convention for a Lisp->C compiler comp.compilers@inglorion.net (Robbert Haarman) (2010-06-07) |
Re: Designing a calling convention for a Lisp->C compiler gene.ressler@gmail.com (Gene) (2010-06-06) |
From: | russell kym horsell <kym@sdf.lonestar.org> |
Newsgroups: | comp.compilers |
Date: | Fri, 4 Jun 2010 04:24:50 +0000 (UTC) |
Organization: | Netfront http://www.netfront.net/ |
References: | 10-06-008 |
Keywords: | C, Lisp, translator, comment |
Posted-Date: | 04 Jun 2010 12:21:20 EDT |
Manuel <msimoni@gmail.com> wrote:
> Hello group!
> I am building a Lisp to C compiler. I don't know very much about the
> lowlevel details of things like stdarg, so I it is rather unclear for
> me how to go about making this as efficient as possible.
[...]
The "bull at a gate" approach doesn't work very well for
applicative/functional languages.
While some very simple LISP programs -- i.e. written by people that
normally program in C or whatever -- may be relatively straightforward to
turn (back:) into C.
But LISP programmers generally make so much use of the "data == program"
idea that no simple translation is practical.
The tried-and-true method is to decide on some kind of abstract machine
that can execute programs in the language you have in mind (e.g. SECD machine),
translate your applicative language efficiently into THAT (normally quite
a trick, but a worthy learning experience :), and then -- possibly --
write each "machine instruction" in the abstract machine as a C macro
and -- thence -- have a system that can compile your applicative language.
There are many books on compiling functional languages such as ML, Miranda or
even one or other dialect of LISP/Scheme. Give some a skim.
And maybe check out the FAQ at comp.lang.functional for further pointers
on compiling same.
Good luck. :)
[I dunno. People have been compiling Lisp into machine code quite successfully
since the mid 1960s. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.