From: Binary
Subject: simplest LISP interpreter
Date: 
Message-ID: <1112595412.695714.233490@f14g2000cwb.googlegroups.com>
HI all,

Anyone knows the simplest LISP interpreter, I want to know how it
works.

Any help appreciated!

Binary

From: Kent M Pitman
Subject: Re: simplest LISP interpreter
Date: 
Message-ID: <ud5tb6nih.fsf@nhplace.com>
"Binary" <···········@gmail.com> writes:

> HI all,
> 
> Anyone knows the simplest LISP interpreter,

I assume this is a question.  I believe the answer is, approximately:

(defun lisp ()
  (write-line "Storage exhausted."))

> I want to know how it works.

The way it works is by exploiting the fact that implementations are
permitted to have resource limitations of various kinds, and that if
you make sure such limitations come into play early enough, you can
avoid writing a lot of clumsy stuff that opens and closes files, etc.
This makes it probably not very commercially interesting, but still
probably the smallest of any conforming Lisp processors.

And it hopefully hints at the notion that perhaps seeking out the
simplest is not really going to be what you really need...

> Any help appreciated!

Sure, here are a couple of remarks that might help you:

First: Don't begin with the study of language interpreters or
compilers; instead, study programming.  The Lisp language is
deliberately large on the assumption that people don't write language
processors (compilers and interpreters) often, and it mostly only
matters that it is a doable task, not that everyone be able to do it.
Also, contrary to the wild claims of some, the size of the
implementation is not proven to be correlated to the ease of
programming it.  [Similarly, "simple" human languages (such as
esperanto) are not widely accepted by users as more useful in practice
than more complex human languages.]

Incidentally, Lisp is not an "interpreted" language.  Please don't
think of it that way.  As a definitional matter, interpreting code is
permitted of conforming processors, but not required.  Ditto
compilation.  The semantics of Lisp are defined in a way that unifies
these two models.  In practice, Lisp is ordinarily compiled by anyone
doing serious programming and by almost every conforming ANSI CL
processor.
From: Steven M. Haflich
Subject: Re: simplest LISP interpreter
Date: 
Message-ID: <u3l6e.300$J12.94@newssvr14.news.prodigy.com>
First, I want to endorse Kent's comments strongly.  Implementing
a language is probably the best way to understand what is unimportant
about a lanaguage and to miss completel;y what is important about a
language:  How is it used?

To prove this point, please Google "lisp in awk" (use thw quoted
string) and you will find copies of Roger Rohrbach's cute lisp
implementation in Awk.  It is a counterexample of counterexamples
of language implementation.

It would be better for you to find three or five extended good
programs written in Common Lisp and study how they are written.
You could start here, especially the first example:
http://www.dynamiclearningcenter.com/samples/index.html
From: André Thieme
Subject: Re: simplest LISP interpreter
Date: 
Message-ID: <d2qqfv$8ej$1@ulric.tng.de>
Binary schrieb:

> Anyone knows the simplest LISP interpreter, I want to know how it works.

On the read-eval-print-loop you could type:

(loop (print (eval (read))))


Andr�
--
From: Karl A. Krueger
Subject: Re: simplest LISP interpreter
Date: 
Message-ID: <d2sb7s$8eo$1@baldur.whoi.edu>
Andr? Thieme <······························@justmail.de> wrote:
> Binary schrieb:
>> Anyone knows the simplest LISP interpreter, I want to know how it works.
> 
> On the read-eval-print-loop you could type:
> (loop (print (eval (read))))

Ah, but how it works was the other part of M. Binary's question --

The READ function takes in character input, and turns it into syntax
trees.  The EVAL function compiles and runs (or, sometimes, interprets)
those syntax trees, yielding result data.  The PRINT function turns
result data back into characters and outputs them.  And LOOP does it all
over again, in the same dynamic environment.

The clever part seems to be that in Lisp this sort of thing is not a
"trick answer" or a cheat.  Researchers in the early 1960s invented the
self-hosting compiler by writing a compiler in Lisp and running it on
itself in a Lisp interpreter.

(Yes, the idea of a self-hosting compiler -- a compiler written in a
high-level language, that can compile itself -- had to be invented.  It
was invented at MIT using LISP 1.5.  Previous compilers for FORTRAN and
COBOL were written in assembly language.)

-- 
Karl A. Krueger <········@example.edu> { s/example/whoi/ }
From: Pascal Costanza
Subject: Re: simplest LISP interpreter
Date: 
Message-ID: <3bcaffF6figtdU1@individual.net>
Binary wrote:
> HI all,
> 
> Anyone knows the simplest LISP interpreter, I want to know how it
> works.
> 
> Any help appreciated!

Kent's statements are very important, but also check out 
http://www.paulgraham.com/rootsoflisp.html


Pascal
From: Simo Melenius
Subject: Re: simplest LISP interpreter
Date: 
Message-ID: <87r7hrhs1h.fsf@sme.intra.citec.fi>
"Binary" <···········@gmail.com> writes:

> Anyone knows the simplest LISP interpreter, I want to know how it
> works.

First study the basics of how Lisp code is evaluated and then write a
simple interpreter yourself to do that. You'll learn more in that
process and most importantly, it's fun as hell!

Every man will eventually reach an age where he either writes a toy
Lisp implementation or withers away to waste the rest of his life on
something else. ;)


t:s

-- 
··················@iki.fi-spam
From: Pascal Bourguignon
Subject: Re: simplest LISP interpreter
Date: 
Message-ID: <87y8byn9ig.fsf@thalassa.informatimago.com>
"Binary" <···········@gmail.com> writes:
> Anyone knows the simplest LISP interpreter, I want to know how it
> works.

Have a look at the end of the page:

    http://www.informatimago.com/develop/lisp/small-cl-pgms/index.html

aim-8.lisp is a small LISP interpreter (written in Common-Lisp), and
aim-8.aim-8 is a small LISP interpreter (written in AIM-8 LISP).


Another good reference is:

    http://mitpress.mit.edu/sicp/
    http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-26.html#%_sec_4.1


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

In a World without Walls and Fences, 
who needs Windows and Gates?
From: Sampo Smolander
Subject: Re: simplest LISP interpreter
Date: 
Message-ID: <d2rijj$c77$1@oravannahka.helsinki.fi>
Binary <···········@gmail.com> wrote:
> Anyone knows the simplest LISP interpreter,

There was one pretty small in the Obfuscated C code contest 1989:

http://www.ioccc.org/1989/jar.2.c

http://www.ioccc.org/1989/jar.2.hint

(That jar in the filenames comes from the author's name, Jari.
Absolutely nothing to do with Java. Anyway Java was probably
quite unheard of in 1989.)
From: Binary
Subject: Re: simplest LISP interpreter
Date: 
Message-ID: <1112663710.967366.99750@l41g2000cwc.googlegroups.com>
How to compile jar.2.c ?

Binary
From: Pascal Bourguignon
Subject: Re: simplest LISP interpreter
Date: 
Message-ID: <87y8bykmjz.fsf@thalassa.informatimago.com>
"Binary" <···········@gmail.com> writes:

> How to compile jar.2.c ?

Not with gcc...

Unless you substitute #define for #d and #include for #a, removing the
first two lines.

sed -e 1,2d -e 's/#a /#include /' -e 's/#d /#define /' <jar.2.c >jar.c
gcc -o jar jar.c

./jar<<EOF
(defun fact (x) (if (< 0 x) (* x (fact (- x 1))) 1))
(fact 3)
(fact 10)
EOF



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we. -- Georges W. Bush
From: Barry Margolin
Subject: Re: simplest LISP interpreter
Date: 
Message-ID: <barmar-59B027.15101604042005@comcast.dca.giganews.com>
In article <························@f14g2000cwb.googlegroups.com>,
 "Binary" <···········@gmail.com> wrote:

> HI all,
> 
> Anyone knows the simplest LISP interpreter, I want to know how it
> works.

There's something called SIOD, for Scheme In One Defun, written by 
George Carrette.

http://people.delphiforums.com/gjc/siod.html

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***