Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Lisp interpreter

Name: Anonymous 2010-02-08 7:56

I'm thinking of writing a lisp interpreter in lisp. Any ideas?

Name: Anonymous 2010-02-08 7:59

OP here I meant python, sorry.

Name: Anonymous 2010-02-08 8:00

Eval/Apply

Name: Anonymous 2010-02-08 8:03

Name: Anonymous 2010-02-08 8:34

>>1
You can do one in like a page or two of code, and there's so many examples. Look into meta-circular interpreter's.
Some books that show examples: SICP(Scheme), PAIP(Scheme in CL, since Scheme is easier to implement, has a compiler too), Graham's Roots of Lisp (http://www.paulgraham.com/rootsoflisp.html - it's simpler than more real interpreters as it doesn't have a real lexical environment), Lisp in Small Pieces (this is a book dedicated to writing Lisp/Scheme interpreters and compilers, there's multiple versions here). Aside from that, there's so many toy metacircular implementations floating around the Internet, so just search a bit, and most implementations come with EVAL, so you can look into that, however I've seen CL implementations that don't have a real EVAL, instead it's just a simple(from memory, untested):

(defun eval (body)
  (funcall (compile nil `#'(lambda () ,@body))))

Name: Anonymous 2010-02-08 8:40

>>2
So a python interpter in lisp? cl-python, except i think it was a compiler (compiles to CL code and if the underlying CL compiles to native code, then you get free native codegen).

Name: Anonymous 2010-02-08 9:40

why would anyone do this

Name: Anonymous 2010-02-08 9:46

>>7
Most people do it to learn Lisp better, others do it if they're working on their own variant. In general, if you want neither, then you don't really have to do this as there's many implementations already. It's also much easier to write interpreters in Lisp as code is also data, which means people don't have to write their own READ(lexer/parser), and one can usually reuse a lot of primitives as well if the target language is the same as the source language. It's usually doable in a few pages of code, which means it's a fun exercise which shows you understand the language. You don't see people doing this as much in other languages since they'd have to implement their own lexer/parser as well, which is a bit more involved.

Name: Anonymous 2010-12-17 1:24

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-02-04 19:15

Name: Anonymous 2011-02-17 19:42

that's cool and all, but check 'em
Don't change these.
Name: Email:
Entire Thread Thread List