From: Thaddeus L Olczyk
Subject: How to write a Lisp engine?
Date: 
Message-ID: <3c2aa63d.1359602468@nntp.interaccess.com>
Can anyone suggest references for writing a Lisp engine?
In particular what the C core has to support in terms of Lisp
functionality in order for the rest  to be writtenin Lisp.

From: Kenny Tilton
Subject: Re: How to write a Lisp engine?
Date: 
Message-ID: <3C2AF645.FAA53751@nyc.rr.com>
As far as books go, your post just reminded me to order "lisp in small
pieces" from amazon, $80. Norvig has a very positive review there as
well for the book.

And IIANM, CMUCL and CormanCL come with source. There is OpenMCL as
well, I believe.

kenny
clinisys

Thaddeus L Olczyk wrote:
> 
> Can anyone suggest references for writing a Lisp engine?
> In particular what the C core has to support in terms of Lisp
> functionality in order for the rest  to be writtenin Lisp.
From: Ed LeBouthillier
Subject: Re: How to write a Lisp engine?
Date: 
Message-ID: <3c2b3e05.718013@news.earthlink.net>
On Thu, 27 Dec 2001 04:46:14 GMT, ······@interaccess.com (Thaddeus L
Olczyk) wrote:

>Can anyone suggest references for writing a Lisp engine?
>In particular what the C core has to support in terms of Lisp
>functionality in order for the rest  to be writtenin Lisp.
>

Look at the source code for XLISP.

There are also a few other places, but they're hard to find. AI Expert
magazine did a few articles on writing a tutorial LISP interpreter in
the late 1980's. They used Pascal.

Cheers,
Ed
From: Dr. Edmund Weitz
Subject: Re: How to write a Lisp engine?
Date: 
Message-ID: <m3wuz8abre.fsf@bird.agharta.de>
······@interaccess.com (Thaddeus L Olczyk) writes:

> Can anyone suggest references for writing a Lisp engine?
> In particular what the C core has to support in terms of Lisp
> functionality in order for the rest  to be writtenin Lisp.

Let's see...

1. The most current dead-tree book seems to be 'Lisp in Small Pieces'
   (LiSP). You can find it at

     <http://youpou.lip6.fr/queinnec/WWW/LiSP.html>

2. Many people will probably recommend 'The Anatomy of Lisp' by John
   Allen (ISBN 0-07-001115-X), but - alas - it's not available
   anymore. Also, it describes Pre-ANSI-CL (dynamically scoped)
   implementations.

3. A book describing the implementation of a simple interpreter
   (including the C source code) is available for free at

     <http://www.civilized.com/LispBook/>

   This might come closest to your question.

4. The ALU has an extensive list at

     <http://www.lisp.org/table/books.htm#impl>

5. As others have already mentioned, you can always look at the source
   code of CMUCL, SBCL, CLISP, ECL(S), CormanLisp, ...

HTH,
Edi.
From: Kurt B. Kaiser
Subject: Re: How to write a Lisp engine?
Date: 
Message-ID: <m3sn9wo909.fsf@float.ne.mediaone.com>
······@interaccess.com (Thaddeus L Olczyk) writes:

> Can anyone suggest references for writing a Lisp engine?
> In particular what the C core has to support in terms of Lisp
> functionality in order for the rest  to be writtenin Lisp.

The main references are Queinnec, "Lisp in Small Pieces" and Allen, "Anatomy of
Lisp." However, to understand these you should first master the final chapter
of Ableson and Sussman, "Structure and Interpretation of Computer Programs."
There are also quite a few papers on garbage collection and other low level
topics available online.

Check out CMUCL: www.cons.org/cmucl   and
Steel Bank Lisp: sbcl.sourceforge.net   for CL implementations.

The SBCL entry point is in the CVS at .../src/runtime/runtime.c, and the
contents of the runtime directory should give you an idea of what parts are
implemented in C and assembler. 

My question would be, how low can you go in the host lisp? Is it practical
these days to completely eliminate the C once you have a native code CL
compiler running?

Bootstrapping is a very interesting topic (at least for me :). The Scheme48
guys (s48.org) implemented a small "pre-scheme" compiler to C and bootstrapped
full Scheme on top of that.  They left the pre-scheme in the distribution so
you can see how the bootstrap was accomplished.

There's a _substantial_ difference between the toys of Queinnec/SICP and a CL
implementation, but you have to learn to crawl before you can try pole
vaulting =)

Regards, KBK
From: Reini Urban
Subject: Re: How to write a Lisp engine?
Date: 
Message-ID: <3c2c72b4.111671415@news.tu-graz.ac.at>
Kurt B. Kaiser wrote:
>There's a _substantial_ difference between the toys of Queinnec/SICP and a CL
>implementation, but you have to learn to crawl before you can try pole
>vaulting =)

I would object to the term "toys" for Queinnec/SICP compared to a CL
implementation.

Queinnec discusses rather advanced topics not to be found in any CL
implementation: call/cc and a continuation passing evaluator - chap 3 -
or first class environments - chap 8 - e.g.
In fact Queinnec leaves simple CL from chap 3 until 5 and then again
chap 8.

The real CL's which come with source (CMUCSL/SBCL/Corman/CLISP) provide
much more core support than one would need for such a minimalistic
project, so I cannot really recommend them. tinylisp maybe.
Books are much better for this.

Thaddeus asked for the most primitive functions on which one can
bootstrap from lisp. The answer is in most lisp books, the best of
course LiSP http://youpou.lip6.fr/queinnec/WWW/LiSP.html or his nano
interpreter, but also the Winston/Horn book, Graham's ANSI CL and most
Scheme books. 

I've lent it away, so I cannot give you the exact answer, but out of my
head it would be: 

functions: car, cdr, cons, eq, lambda, if, read-char, write-char
symbols: T, nil

For not so pure lisps also a setter function (set or define) and quote.
read-char and write-char are only needed to save and restore state.

Then some support for simple types (numbers, strings, ...) like +, -, *,
... The more, the better.

Please correct me if I'm wrong. I'm not sure about if/apply/lambda. 
esp. with APPLY one case construct a lisp LAMBDA and vice versa. 
With IF a simple cond and then apply.

Quenniec uses in FEMTO: http://youpou.lip6.fr/queinnec/Papers/nano.ps.gz
only: car, cdr, rplaca, rplacd, read-char, write-char, end

Obscure books like "The Computational Beauty of Nature" for example has
such a minimalistic lisp without any numbers.
http://hornacek.coa.edu/dave/Teaching/Chaotic_Dynamics/Flake/stutter.html

which has car, cdr, cons, if, set, equal, quote, and lambda

Chaitin is also in this league:
http://www.cs.auckland.ac.nz/CDMTCS/chaitin/rov.html with
http://www.cs.auckland.ac.nz/CDMTCS/chaitin/lisp.c as c src.
He has quote, eq, atom, car, cdr, cons, lambda, define, let, if, display
and eval, which is much more then one really would need.
-- 
Reini Urban
http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html
From: Kurt B. Kaiser
Subject: Re: How to write a Lisp engine?
Date: 
Message-ID: <m3g05uoec3.fsf@float.ne.mediaone.com>
······@x-ray.at (Reini Urban) writes:
> Kurt B. Kaiser wrote:
> >There's a _substantial_ difference between the toys of Queinnec/SICP and a
> >CL implementation, but you have to learn to crawl before you can try pole
> >vaulting =)
> 
> I would object to the term "toys" for Queinnec/SICP compared to a CL
> implementation.
> 
> Queinnec discusses rather advanced topics not to be found in any CL
> implementation: call/cc and a continuation passing evaluator - chap 3 -
> or first class environments - chap 8 - e.g.
> In fact Queinnec leaves simple CL from chap 3 until 5 and then again
> chap 8.
> 
> The real CL's which come with source (CMUCSL/SBCL/Corman/CLISP) provide
> much more core support than one would need for such a minimalistic
> project, so I cannot really recommend them. tinylisp maybe.
> Books are much better for this.

In no way did I mean to denigrate Queinnec or SICP. I've spent many happy hours
with them. "Toys" is definitely not the best choice of words, but I'm having
some difficulty coming up with a word which expresses "elegant implementation
(with limited functionality) of the essence of an entity."

As I tried to say in my message, a studying a "real" implementation is a hard
way to start. The reduced scope of the examples given in the books, and with
their accompanying explanations, is much easier to understand.

The Femto paper is great. It seems to have things which are not in LiSP, even
though the latter was published later.  Some parts are clearly a warmup for
LiSp.  Femto is an interpreter in 500 lines of Lisp "that, if efficiency is not
the main requirement, can easily be turned into a stand alone program."

Versions in C are interesting and avoid metacircular confusions, but I like my
Lisp in Lisp. :)

McCarthy wrote "A Micromanual for Lisp - Not the Whole Truth" in 1978, the
"shortest article ever written that still presents an evaluator," according to
Queinnec.

Then Queinnec (in 1989) presents "Lisp - Almost a Whole Truth!" in 28 pages.

Regards, KBK
From: Marc Spitzer
Subject: Re: How to write a Lisp engine?
Date: 
Message-ID: <slrna2qif7.fif.marc@oscar.eng.cv.net>
In article <··············@float.ne.mediaone.com>, Kurt B. Kaiser wrote:
> ······@x-ray.at (Reini Urban) writes:
>> Kurt B. Kaiser wrote:
>> >There's a _substantial_ difference between the toys of Queinnec/SICP and a
>> >CL implementation, but you have to learn to crawl before you can try pole
>> >vaulting =)
>> 
>> I would object to the term "toys" for Queinnec/SICP compared to a CL
>> implementation.
>> 
>> Queinnec discusses rather advanced topics not to be found in any CL
>> implementation: call/cc and a continuation passing evaluator - chap 3 -
>> or first class environments - chap 8 - e.g.
>> In fact Queinnec leaves simple CL from chap 3 until 5 and then again
>> chap 8.
>> 
>> The real CL's which come with source (CMUCSL/SBCL/Corman/CLISP) provide
>> much more core support than one would need for such a minimalistic
>> project, so I cannot really recommend them. tinylisp maybe.
>> Books are much better for this.
> 
> In no way did I mean to denigrate Queinnec or SICP. I've spent many happy hours
> with them. "Toys" is definitely not the best choice of words, but I'm having
> some difficulty coming up with a word which expresses "elegant implementation
> (with limited functionality) of the essence of an entity."
> 

Academic?  Well someone had to say it, didn't they?

marc